xAI

xAI Complete API

The Complete API from xAI — 1 operation(s) for complete.

Operations 1

POST /v1/complete (Legacy - Not supported by reasoning models) Create a text completion response. #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/xai:xai-complete-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

xai-complete-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: xAI's REST Complete API
  description: REST API for xAI compatible with other providers.
  license:
    name: ''
  version: 1.0.0
tags:
- name: Complete
paths:
  /v1/complete:
    post:
      tags:
      - Complete
      summary: (Legacy - Not supported by reasoning models) Create a text completion response.
      operationId: handle_generic_complete_request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompleteRequest'
            example:
              model: grok-3
              max_tokens_to_sample: 8
              temperature: 0.1
              prompt: '


                Human: Hello, how are you?


                Assistant:'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompleteResponse'
              example:
                type: completion
                id: 982044c5-760c-4c8d-8936-f906b5cedc26
                completion: ' Hey there! I''m doing great, thanks'
                stop_reason: max_tokens
                model: grok-3
        '400':
          description: Bad request. The request is invalid or an invalid API key is provided.
        '422':
          description: Unprocessable Entity. There are missing fields in the request body.
      security:
      - bearerAuth: []
components:
  schemas:
    CompleteResponse:
      type: object
      description: (Legacy) Anthropic compatible complete response on `/v1/complete` endpoint.
      required:
      - type
      - id
      - completion
      - model
      properties:
        completion:
          type: string
          description: The completion content up to and excluding stop sequences.
        id:
          type: string
          description: ID of the completion response.
        model:
          type: string
          description: The model that handled the request.
        stop_reason:
          type:
          - string
          - 'null'
          description: The reason to stop completion. `"stop_sequence"` means the inference has reached a model-defined or user-supplied stop sequence in `stop`. `"length"` means the inference result has reached models' maximum allowed token length or user defined value in `max_tokens`. `"end_turn"` or `null` in streaming mode when the chunk is not the last.
        type:
          type: string
          description: Completion response object type. This is always `"completion"`.
    CompleteRequest:
      type: object
      description: (Legacy) Anthropic compatible complete request on `/v1/complete` endpoint.
      properties:
        max_tokens_to_sample:
          type: integer
          format: int32
          description: The maximum number of tokens to generate before stopping.
        metadata:
          oneOf:
          - type: 'null'
          - $ref: '#/components/schemas/MessageMetadata'
            description: An object describing metadata about the request.
        model:
          type: string
          description: Model to use for completion.
        prompt:
          type: string
          description: Prompt for the model to perform completion on.
        stop_sequences:
          type:
          - array
          - 'null'
          items:
            type: string
          description: (Not supported by reasoning models) Up to 4 sequences where the API will stop generating further tokens.
        stream:
          type:
          - boolean
          - 'null'
          description: '(Unsupported) If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message.'
        temperature:
          type:
          - number
          - 'null'
          format: float
          description: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
          default: 1
          example: 0.2
          maximum: 2
          minimum: 0
        top_k:
          type:
          - integer
          - 'null'
          format: int32
          description: (Unsupported) When generating next tokens, randomly selecting the next token from the k most likely options.
        top_p:
          type:
          - number
          - 'null'
          format: float
          description: An alternative to sampling with `temperature`, called nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. It is generally recommended to alter this or `temperature` but not both.
          default: 1
          maximum: 1
          exclusiveMinimum: 0
    MessageMetadata:
      type: object
      properties:
        user_id:
          type:
          - string
          - 'null'
          description: A unique identifier representing your end-user, which can help xAI to monitor and detect abuse.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer