---
title: "LLM"
method: POST
path: "/api/generate/llm"
tags: ["generate"]
---

# LLM

`POST /api/generate/llm`

## Request

- The document declares no server URL.
- Auth: none declared

Generate text using a language model.

## Request body

- LLMRequest
  - `messages` LLMMessage[], required
    - `role` string, required
    - `content` string, required
  - `model` string
  - `temperature` number
  - `max_tokens` integer
  - `top_p` number
  - `top_k` integer
  - `stream` boolean

## Response `200`

Successful Response

- LLMResponse
  - `id` string, required
  - `model` string, required
  - `created` integer, required
  - `usage` LLMTokenUsage, required
    - `prompt_tokens` integer, required
    - `completion_tokens` integer, required
    - `total_tokens` integer, required
  - `choices` LLMChoice[], required
    - `index` integer, required
    - `finish_reason` string
    - `delta` LLMMessage
      - `role` string, required
      - `content` string, required
    - `message` LLMMessage
      - `role` string, required
      - `content` string, required

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `422`: Validation Error
- `500`: Internal Server Error
- `default`: Error

## Changes

- **2025-10-30** `dfc937fc0d2c`: 12 breaking, 5 info
  - the `choices/items/delta` response's property type changed from `object` to no type for status `200`
  - the `choices/items/message` response's property type changed from `object` to no type for status `200`
  - the `oneOf[subschema #1: HTTPError]/detail` response's property type changed from `object` to no type for status `400`
  - the `oneOf[subschema #1: HTTPError]/detail` response's property type changed from `object` to no type for status `401`
  - …13 more
- **2025-10-30** `f5d01b71ba9a`: 5 breaking, 12 info
  - the `choices/items/delta` response's property type changed from no type to `object` for status `200`
  - the `choices/items/message` response's property type changed from no type to `object` for status `200`
  - the `oneOf[subschema #1: HTTPError]/detail` response's property type changed from no type to `object` for status `400`
  - the `oneOf[subschema #1: HTTPError]/detail` response's property type changed from no type to `object` for status `401`
  - …13 more
- **2025-10-28** `dfc937fc0d2c`: 3 breaking, 6 info
  - removed the media type `application/x-www-form-urlencoded` from the request body
  - removed the required property `response` from the response with the `200` status
  - removed the required property `tokens_used` from the response with the `200` status
  - added the media type `application/json` to the request body
  - …5 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/livepeer/apis/livepeer-ai-api/changes/api/generate/llm/post.md)

---

[API](https://skmtc.dev/livepeer/apis/livepeer-ai-api.md) - [All operations](https://skmtc.dev/livepeer/apis/livepeer-ai-api/llms.txt) - [OpenAPI document](https://skmtc.dev/livepeer/apis/livepeer-ai-api/revisions/dfc937fc0d2c?raw)
