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

# Grok All-Model API - Responses Reference

> - OpenAI-compatible Responses endpoint for xAI Grok text models; pick the model via the `model` parameter (see the table on the `model` parameter for all values)
- `grok-4.5`: 500K-token context window; prompts of 200K tokens or more are billed at 2x for all token types
- Prompt caching is automatic: cached prompt tokens are billed at the lower cached-input rate
- Synchronous and streaming (SSE) modes
- xAI server-side tools run on xAI infrastructure and are billed per successful call: `web_search`, `x_search`, `code_execution`, `attachment_search`, `collections_search`
- Regular `function` tools (client-side function calling) are also supported and carry no per-call fee

<Note>
  **BaseURL**: The default BaseURL is `https://direct.evolink.ai`, which has better support for text models and long-lived connections. `https://api.evolink.ai` is the primary endpoint for multimodal services and serves as a fallback address for text models.
</Note>

<Note>
  **Server-side tools** run on xAI's infrastructure and are billed per successful call in addition to token usage: Web Search / X Search / Code Execution $0.005 per call, Attachment Search $0.01 per call, Collections Search \$0.0025 per call. Tool fees are not affected by the long-context multiplier.
</Note>

<Warning>
  `image_generation` is currently not available on Grok 4.5: declaring it is accepted for compatibility but the tool is removed before the request reaches the model. Unrecognized `tools[].type` values are rejected with `400`.
</Warning>


## OpenAPI

````yaml en/api-manual/language-series/grok/responses/responses-reference.json POST /v1/responses
openapi: 3.1.0
info:
  title: Grok All-Model API - Responses Reference
  description: >-
    Full parameter reference for calling xAI Grok text models through the
    OpenAI-compatible Responses API, including server-side tools.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: Production (recommended)
  - url: https://api.evolink.ai
    description: Alternative URL
security:
  - bearerAuth: []
tags:
  - name: Responses
    description: OpenAI Responses API with xAI server-side tools
paths:
  /v1/responses:
    post:
      tags:
        - Responses
      summary: Grok Responses (All Models, Full Parameters)
      description: >-
        - OpenAI-compatible Responses endpoint for xAI Grok text models; pick
        the model via the `model` parameter (see the table on the `model`
        parameter for all values)

        - `grok-4.5`: 500K-token context window; prompts of 200K tokens or more
        are billed at 2x for all token types

        - Prompt caching is automatic: cached prompt tokens are billed at the
        lower cached-input rate

        - Synchronous and streaming (SSE) modes

        - xAI server-side tools run on xAI infrastructure and are billed per
        successful call: `web_search`, `x_search`, `code_execution`,
        `attachment_search`, `collections_search`

        - Regular `function` tools (client-side function calling) are also
        supported and carry no per-call fee
      operationId: grokResponsesReference
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesRequest'
      responses:
        '200':
          description: >-
            Response generated successfully (JSON object, or an SSE event stream
            ending with `response.completed` when `stream=true`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponsesResponse'
        '400':
          description: >-
            Invalid request parameters (including unrecognized `tools[].type`
            values, which are rejected before reaching the model)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 400
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: Unauthorized, invalid or expired token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: >-
            Insufficient quota. Declaring paid server-side tools reserves the
            worst-case tool budget upfront; the unused reservation is refunded
            at settlement.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 402
                  message: Insufficient quota
                  type: insufficient_quota_error
                  fallback_suggestion: https://evolink.ai/dashboard/billing
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 429
                  message: Rate limit exceeded
                  type: rate_limit_error
                  fallback_suggestion: retry after 60 seconds
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 500
                  message: Internal server error
                  type: internal_server_error
                  fallback_suggestion: try again later
        '503':
          description: Service temporarily unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 503
                  message: Service temporarily unavailable
                  type: service_unavailable_error
                  fallback_suggestion: retry after 30 seconds
components:
  schemas:
    ResponsesRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: |-
            Model to call:

            | Model ID | Positioning |
            |---|---|
            | `grok-4.5` | xAI reasoning + tool-use model, 500K context window |
          enum:
            - grok-4.5
          example: grok-4.5
        input:
          description: >-
            Input for the model: a plain string, or an array of OpenAI Responses
            input items (e.g. `{"role":"user","content":[...]}`), passed through
            as-is.
          oneOf:
            - type: string
            - type: array
              items:
                type: object
          example: >-
            Search the web for the latest SpaceX launch and summarize it in one
            sentence.
        stream:
          type: boolean
          description: >-
            Whether to return a streaming response (SSE events, ending with
            `response.completed`). Default `false`.
          default: false
          example: false
        max_output_tokens:
          type: integer
          description: Maximum number of tokens to generate (reasoning tokens included).
          example: 2048
        tools:
          type: array
          description: >-
            Tool declarations. xAI server-side tools (billed per successful
            call, fees not affected by the long-context multiplier):


            | Tool type | What it does | Price per call |

            |---|---|---|

            | `web_search` | Search the internet and browse web pages | $0.005 |

            | `x_search` | Search X posts, profiles, and threads | $0.005 |

            | `code_execution` | Run Python in a sandbox (`code_interpreter`
            accepted as alias) | $0.005 |

            | `attachment_search` | Search files attached to the conversation
            (may be auto-enabled when the input contains files) | $0.01 |

            | `collections_search` | Query uploaded document collections
            (`file_search` accepted as alias) | $0.0025 |


            Regular `function` tools (client-side function calling) are also
            supported and carry no per-call fee.


            ⚠️ `image_generation` is currently not available: declaring it is
            accepted for compatibility but removed before the request reaches
            the model. Unrecognized tool types are rejected with `400`.
          items:
            $ref: '#/components/schemas/Tool'
          example:
            - type: web_search
        tool_choice:
          description: >-
            Controls tool selection: `"auto"` (default) / `"none"` /
            `"required"`, or an object pinning a specific tool, e.g. `{"type":
            "web_search"}`.
          oneOf:
            - type: string
              enum:
                - auto
                - none
                - required
            - type: object
        max_tool_calls:
          type: integer
          description: >-
            Maximum number of server-side tool calls for this request. When
            omitted (or set to `null`), the platform automatically applies a cap
            of up to 10 calls based on your available balance. Declared paid
            tools reserve their worst-case budget upfront; the unused part is
            refunded at settlement.
          example: 5
    ResponsesResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the response
          example: 55d44212-8d5e-90cc-975f-36d341ce21f5
        object:
          type: string
          enum:
            - response
          description: Response type
          example: response
        status:
          type: string
          description: Response status
          enum:
            - completed
            - incomplete
            - failed
          example: completed
        model:
          type: string
          description: Model name actually used
          example: grok-4.5
        created_at:
          type: integer
          description: Creation timestamp
          example: 1786538000
        output:
          type: array
          description: >-
            Output items in generation order: `reasoning` items (summarized
            thinking), server-side tool call items such as `web_search_call` /
            `code_interpreter_call` (status `completed` marks a successful,
            billable call), and a final `message` item with `output_text`
            content.
          items:
            $ref: '#/components/schemas/OutputItem'
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP status error code
            message:
              type: string
              description: Error description
            type:
              type: string
              description: Error type
            param:
              type: string
              description: Related parameter name
            fallback_suggestion:
              type: string
              description: Suggestion when error occurs
    Tool:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          description: Tool type
          enum:
            - web_search
            - x_search
            - code_execution
            - code_interpreter
            - attachment_search
            - collections_search
            - file_search
            - function
          example: web_search
    OutputItem:
      type: object
      properties:
        id:
          type: string
          description: Output item identifier
        type:
          type: string
          description: Output item type
          enum:
            - reasoning
            - message
            - web_search_call
            - x_search_call
            - code_interpreter_call
            - code_execution_call
            - attachment_search_call
            - file_search_call
            - function_call
          example: web_search_call
        status:
          type: string
          description: Output item status; `completed` tool calls are the ones billed
          example: completed
        content:
          type: array
          description: Message content parts (`output_text`), present on `message` items
          items:
            type: object
    Usage:
      type: object
      description: >-
        Token and tool usage statistics. Prompts of 200K tokens or more are
        billed at 2x for all token types; tool fees are unaffected by the
        multiplier.
      properties:
        input_tokens:
          type: integer
          description: Number of input tokens
          example: 10329
        output_tokens:
          type: integer
          description: Number of output tokens (includes reasoning tokens)
          example: 299
        total_tokens:
          type: integer
          description: Total number of tokens
          example: 10628
        input_tokens_details:
          type: object
          description: Detailed input token information
          properties:
            cached_tokens:
              type: integer
              description: >-
                Number of cached prompt tokens hit (billed at the lower
                cached-input rate; caching is automatic)
              example: 6016
        output_tokens_details:
          type: object
          description: Detailed output token information
          properties:
            reasoning_tokens:
              type: integer
              description: Number of reasoning tokens
              example: 128
        num_server_side_tools_used:
          type: integer
          description: Total number of server-side tool calls in this response
          example: 2
        server_side_tool_usage_details:
          type: object
          description: >-
            Per-tool call counts (some third-party routes may omit this object;
            billing then falls back to counting completed tool-call output
            items)
          properties:
            web_search_calls:
              type: integer
              example: 2
            x_search_calls:
              type: integer
              example: 0
            code_interpreter_calls:
              type: integer
              example: 0
            document_search_calls:
              type: integer
              description: Attachment search calls
              example: 0
            file_search_calls:
              type: integer
              description: Collections search calls
              example: 0
            mcp_calls:
              type: integer
              example: 0
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        ##All APIs require Bearer Token authentication##


        **Get API Key:**


        Visit [API Key Management Page](https://evolink.ai/dashboard/keys) to
        get your API Key


        **Add to request header:**

        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````