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

# Responses API

> POST /v1/responses — нативный прокси к Responses API

`/v1/responses` — нативный прокси к [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses). Запрос передаётся провайдеру как есть, ответ возвращается без изменений.

Поддерживается полная функциональность Responses API: tools, structured output, reasoning, `previous_response_id`, web search и другие возможности.

## Примеры

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.routify.ru/v1/responses \
    -H "Authorization: Bearer $ROUTIFY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4.1",
      "input": "Привет! Как дела?"
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="ваш_ключ",
      base_url="https://api.routify.ru/v1"
  )

  response = client.responses.create(
      model="gpt-4.1",
      input="Привет! Как дела?"
  )

  print(response.output_text)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.ROUTIFY_API_KEY,
    baseURL: "https://api.routify.ru/v1",
  });

  const response = await client.responses.create({
    model: "gpt-4.1",
    input: "Привет! Как дела?",
  });

  console.log(response.output_text);
  ```
</CodeGroup>

## Стриминг

```python theme={null}
stream = client.responses.create(
    model="gpt-4.1",
    input="Напиши короткий рассказ",
    stream=True,
)

for event in stream:
    if hasattr(event, "delta"):
        print(event.delta, end="", flush=True)
```

## Биллинг

Тарификация по полям `input_tokens`, `output_tokens` и `cached_tokens` из ответа провайдера. При стриминге — из события `response.completed`.


## OpenAPI

````yaml POST /v1/responses
openapi: 3.1.0
info:
  title: Routify API
  version: 0.1.0
  description: |
    Routify MVP API contract.
    /v1/chat/completions is a strict MVP subset of OpenAI-compatible APIs.
    /v1/responses is a native pass-through proxy to upstream.
servers:
  - url: https://api.routify.ru
    description: Production server
security:
  - bearerAuth: []
tags:
  - name: Chat
  - name: Responses
  - name: Models
paths:
  /v1/responses:
    post:
      tags:
        - Responses
      summary: Create a response (native proxy)
      description: |
        Native pass-through proxy to upstream /v1/responses.
        Request and response bodies are forwarded as-is.
        Streaming uses SSE and ends with [DONE].
        Requires `Authorization: Bearer $ROUTIFY_API_KEY`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              description: >
                Full OpenAI Responses API request. All fields are forwarded to
                the upstream provider as-is. For detailed parameter descriptions
                see
                https://developers.openai.com/api/reference/resources/responses/methods/create
              properties:
                model:
                  type: string
                  description: >
                    Model ID used to generate the response. Use `GET /v1/models`
                    to list all available models.
                input:
                  description: >
                    Text, image, or file inputs to the model, used to generate a
                    response. Can be a string or an array of input items.
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: object
                stream:
                  type: boolean
                  default: false
                  description: >
                    If set to true, the response is streamed using server-sent
                    events. The stream ends with a `response.completed` event.
      responses:
        '200':
          description: Successful response (JSON or SSE stream)
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
            text/event-stream:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '502':
          $ref: '#/components/responses/BadGateway'
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |
            curl https://api.routify.ru/v1/responses \
              -H "Authorization: Bearer $ROUTIFY_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "model": "gpt-4.1",
                "input": "Tell me a short joke."
              }'
        - lang: python
          label: Python
          source: |
            from openai import OpenAI

            client = OpenAI(
                api_key="$ROUTIFY_API_KEY",
                base_url="https://api.routify.ru/v1"
            )

            response = client.responses.create(
                model="gpt-4.1",
                input="Tell me a short joke."
            )
            print(response.output_text)
        - lang: javascript
          label: Node.js
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
              apiKey: process.env.ROUTIFY_API_KEY,
              baseURL: "https://api.routify.ru/v1"
            });

            const response = await client.responses.create({
              model: "gpt-4.1",
              input: "Tell me a short joke."
            });
            console.log(response.output_text);
        - lang: json
          label: Response
          source: |
            {
              "id": "resp_03e9ec3c72006b3e...",
              "object": "response",
              "created_at": 1772530182,
              "status": "completed",
              "model": "gpt-5.1-codex-mini",
              "output": [
                {
                  "type": "message",
                  "status": "completed",
                  "role": "assistant",
                  "content": [
                    {
                      "type": "output_text",
                      "text": "Hello! How can I assist you today?"
                    }
                  ]
                }
              ],
              "usage": {
                "input_tokens": 7,
                "output_tokens": 26,
                "total_tokens": 33
              }
            }
components:
  responses:
    BadRequest:
      description: Invalid request or unsupported field
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              message: model is required
              type: invalid_request_error
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              message: invalid api key
              type: auth_error
    PaymentRequired:
      description: Insufficient balance
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              message: insufficient balance
              type: billing_error
    NotFound:
      description: Model or resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              message: model not found
              type: invalid_request_error
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              message: rate limit exceeded
              type: rate_limit_error
    BadGateway:
      description: Upstream provider failure
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              message: all providers unavailable
              type: provider_error
  schemas:
    ErrorResponse:
      type: object
      additionalProperties: false
      properties:
        error:
          type: object
          additionalProperties: false
          properties:
            message:
              type: string
            type:
              $ref: '#/components/schemas/ErrorType'
          required:
            - message
            - type
      required:
        - error
    ErrorType:
      type: string
      enum:
        - invalid_request_error
        - auth_error
        - billing_error
        - rate_limit_error
        - provider_error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: token
      description: >
        Bearer authentication header of the form `Authorization: Bearer
        $ROUTIFY_API_KEY`.

````