> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aihubmax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 纯文本

> 使用返回的任务 ID [进行查询](/pages/zh/api-manual/task-management/get-task-detail) 获取最终结果。



## OpenAPI

````yaml openapi/zh/llm-text.json POST /v1/llm/generations
openapi: 3.1.0
info:
  title: LLM · llm-text protocol
  version: '1.0'
  description: >-
    统一 LLM 入口的 **`llm-text`** 请求格式：仅 `prompt`（无 `image_urls` / `video_urls` /
    `audio_url` / `messages`）→ 纯文本生成。


    **`/v1/llm/generations` 端点支持 5 种请求形态**：

    - `llm-text`（本文件）：仅 `prompt`

    - `llm-vision`：`prompt` + `image_urls[]`

    - `llm-video`：`prompt` + `video_urls[]`

    - `llm-audio`：`audio_url`

    - `llm-custom`：`messages[]`（OpenAI Chat 兼容）


    任务最终结果通过 `GET /v1/tasks/{task_id}` 查询；SSE 流式订阅端点为 `GET
    /v1/llm/generations/{task_id}/stream`，所有 5 种 protocol 共用。
servers:
  - url: https://api.aihubmax.com
security:
  - BearerAuth: []
paths:
  /v1/llm/generations:
    post:
      tags:
        - LLM > llm-text
      summary: 提交 LLM 生成任务（llm-text 协议）
      description: >-
        使用返回的任务 ID [进行查询](/pages/zh/api-manual/task-management/get-task-detail)
        获取最终结果。
      operationId: llm-text
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LLMTextRequest'
            examples:
              example_0:
                summary: Async non-streaming
                value:
                  model: claude-opus-4-7
                  prompt: Summarize the theory of relativity in two sentences.
                  max_tokens: 64
                  temperature: 0.3
              example_1:
                summary: Sync streaming (SSE response)
                value:
                  model: gemini-2.5-pro
                  prompt: Count from one to five.
                  sync: true
                  stream: true
                  max_tokens: 32
                  system_prompt: You are a terse assistant.
      responses:
        '200':
          description: 任务已创建（async 模式）/ 完整响应（sync 模式）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
              examples:
                non_stream:
                  summary: sync=false, stream=false
                  value:
                    id: task-llmrouter-1776874481-rj6bs3yb
                    object: llm.generation.task
                    type: llm
                    model: claude-opus-4-7
                    status: pending
                    progress: 0
                    created: 1776874481
                    stream: null
                    results: null
                    error: null
                stream:
                  summary: sync=false, stream=true
                  value:
                    id: task-llmrouter-1776874565-yq3szvcu
                    object: llm.generation.task
                    type: llm
                    model: claude-opus-4-7
                    status: pending
                    progress: 0
                    created: 1776874565
                    stream:
                      url: >-
                        /v1/llm/generations/task-llmrouter-1776874565-yq3szvcu/stream
                    results: null
                    error: null
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  schemas:
    LLMTextRequest:
      type: object
      required:
        - model
        - prompt
      additionalProperties: true
      properties:
        model:
          type: string
          description: >-
            [获取模型列表](/pages/zh/api-manual/text-series/llm-async/llm-generations-models)
          example: claude-opus-4-7
        prompt:
          type: string
          maxLength: 100000
          description: 用户提示词，最多 100,000 字符。
          example: Summarize the theory of relativity in two sentences.
        sync:
          type: boolean
          default: false
          description: >-
            同步模式。`true` 时端点阻塞直到上游完成并返回完整响应（如同时 `stream=true`，则返回 SSE 流）；`false`
            时端点立即返回任务 ID，结果通过 `GET /v1/tasks/{task_id}` 或 SSE 端点获取。
          example: false
        stream:
          type: boolean
          default: false
          description: >-
            是否流式。`true` 时 Submit 响应包含 `stream.url` 指向 SSE 订阅路径；流式 chunks 统一为
            OpenAI `chat.completion.chunk` 格式。
          example: false
        max_tokens:
          type: integer
          nullable: true
          minimum: 1
          description: 生成 token 上限。可选。
          example: 64
        temperature:
          type: number
          nullable: true
          minimum: 0
          maximum: 2
          description: 采样温度，区间 [0, 2]。可选。
          example: 0.3
        system_prompt:
          type: string
          nullable: true
          maxLength: 10000
          description: 系统指令，前置到对话上下文。可选，最多 10,000 字符。
          example: You are a terse assistant.
        reasoning:
          type: boolean
          nullable: true
          description: >-
            是否包含 reasoning tokens。透传到上游；具体语义取决于上游模型（gemini-2.5-pro 等思考模型可能要求
            `true`）。
    SubmitResponse:
      type: object
      description: >-
        Submit 响应，对齐统一任务标准形状。`results` / `error` 在 submit 阶段固定为
        `null`，任务完成/失败后通过 `GET /v1/tasks/{task_id}` 返回。`sync=true, stream=false`
        模式下端点直接返回完整 OpenAI ChatCompletion JSON（不走本结构）。
      required:
        - id
        - object
        - type
        - model
        - status
        - progress
        - created
      properties:
        id:
          type: string
          description: 任务 ID，格式 `task-llmrouter-{timestamp}-{8random}`。
          example: task-llmrouter-1776874565-yq3szvcu
        object:
          type: string
          enum:
            - llm.generation.task
          example: llm.generation.task
        type:
          type: string
          enum:
            - llm
          example: llm
        model:
          type: string
          description: 客户端提交的模型名（原样回显）
          example: claude-opus-4-7
        status:
          type: string
          enum:
            - pending
          example: pending
        progress:
          type: integer
          example: 0
        created:
          type: integer
          example: 1776874565
        stream:
          nullable: true
          description: '`stream=true` 时返回 `{url: ...}`；`stream=false` 时为 `null`。'
          oneOf:
            - $ref: '#/components/schemas/StreamInfo'
            - type: 'null'
        results:
          type: array
          nullable: true
          description: >-
            submit 阶段固定 `null`；任务完成后通过 `GET /v1/tasks/{task_id}` 返回，`results[0]`
            为完整 OpenAI `ChatCompletion` 响应。
          items:
            type: object
          example: null
        error:
          type: object
          nullable: true
          description: submit 阶段固定 `null`；任务失败时通过 `GET /v1/tasks/{task_id}` 返回。
          example: null
    StreamInfo:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          example: /v1/llm/generations/task-llmrouter-1776874565-yq3szvcu/stream
    ErrorResponse401:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 未提供认证 token
            type:
              type: string
              example: authentication_error
    ErrorResponse422:
      type: object
      description: >-
        参数校验失败。常见
        `code`：`protocol_not_detectable`、`model_not_registered`、`invalid_param`、`upstream_client_error`。
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: >-
                model 'unknown-model' is not registered on any
                gateway:llm-router:* channel for this user group
            type:
              type: string
              example: invalid_request_error
            code:
              type: string
              example: model_not_registered
    ErrorResponse429:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 请求频率超限
            type:
              type: string
              example: rate_limit_error
    ErrorResponse500:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Internal server error
            type:
              type: string
              example: internal_error
    ErrorResponse503:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 'all 3 candidates exhausted; last error: ...'
            type:
              type: string
              example: upstream_error
            code:
              type: string
              example: all_platforms_exhausted
  responses:
    Unauthorized:
      description: Token 无效或缺失
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse401'
    UnprocessableEntity:
      description: 参数校验失败 / 模型未注册 / 上游 4xx
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse422'
    TooManyRequests:
      description: 请求频率超限
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse429'
    InternalServerError:
      description: 服务器内部错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse500'
    ServiceUnavailable:
      description: 上游服务不可用
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse503'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |-
        所有接口均需要使用 Bearer Token 进行认证。在请求头中添加：

        `Authorization: Bearer YOUR_API_KEY`

        `YOUR_API_KEY` 为 API Token（`sk-...` 格式）。

````