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

# Create a chat completion



## OpenAPI

````yaml /api-reference/openapi.json post /chat/completions
openapi: 3.1.0
info:
  description: >-
    OpenAI-compatible hosted inference for Wally. Usage is billed against
    prepaid credits at the list prices shown in the RunAnywhere console.
  title: RunAnywhere Wally Public Inference API
  version: 2.0.0
servers:
  - description: Wally production inference gateway
    url: https://inference.runanywhere.ai/v1
security:
  - BearerAuth: []
paths:
  /chat/completions:
    post:
      summary: Create a chat completion
      operationId: createChatCompletion
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionsRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ChatCompletionEventStream'
          description: A completion or an SSE stream when stream=true
          headers:
            Access-Control-Expose-Headers:
              description: Response headers a browser client may read
              schema:
                $ref: '#/components/schemas/AccessControlExposeHeaders'
            Server-Timing:
              description: Pre-stream phase timings when supplied
              schema:
                $ref: '#/components/schemas/ServerTiming'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    ChatCompletionsRequest:
      additionalProperties: false
      properties:
        frequency_penalty:
          maximum: 2
          minimum: -2
          type: number
        max_completion_tokens:
          maximum: 1048576
          minimum: 1
          type: integer
        max_tokens:
          maximum: 1048576
          minimum: 1
          type: integer
        messages:
          items:
            $ref: '#/components/schemas/ChatMessage'
          maxItems: 4096
          minItems: 1
          type: array
        model:
          $ref: '#/components/schemas/ModelId'
        'n':
          maximum: 16
          minimum: 1
          type: integer
        parallel_tool_calls:
          type: boolean
        presence_penalty:
          maximum: 2
          minimum: -2
          type: number
        reasoning_effort:
          $ref: '#/components/schemas/ReasoningEffort'
        response_format:
          $ref: '#/components/schemas/ResponseFormat'
        seed:
          maximum: 9223372036854776000
          minimum: -9223372036854776000
          type: integer
        stop:
          $ref: '#/components/schemas/StopSequenceSet'
        store:
          default: false
          type: boolean
        stream:
          default: false
          type: boolean
        stream_options:
          $ref: '#/components/schemas/StreamOptions'
        temperature:
          maximum: 2
          minimum: 0
          type: number
        tool_choice:
          $ref: '#/components/schemas/ToolChoice'
        tools:
          items:
            $ref: '#/components/schemas/ChatTool'
          maxItems: 128
          minItems: 1
          type: array
        top_p:
          maximum: 1
          minimum: 0
          type: number
        user:
          $ref: '#/components/schemas/EndUserId'
      required:
        - model
        - messages
      type: object
    ChatCompletion:
      additionalProperties: false
      properties:
        choices:
          items:
            $ref: '#/components/schemas/CompletionChoice'
          maxItems: 16
          minItems: 1
          type: array
        created:
          minimum: 0
          type: integer
        id:
          $ref: '#/components/schemas/CompletionId'
        metadata:
          $ref: '#/components/schemas/CompletionMetadata'
        model:
          $ref: '#/components/schemas/CompletionModelId'
        object:
          const: chat.completion
        system_fingerprint:
          anyOf:
            - $ref: '#/components/schemas/CompletionSystemFingerprint'
            - type: 'null'
        usage:
          $ref: '#/components/schemas/CompletionUsage'
      required:
        - id
        - object
        - created
        - model
        - choices
      type: object
    ChatCompletionEventStream:
      description: >-
        SSE frames named message carry ChatCompletionChunk JSON and the stream
        terminates with data: [DONE]. A stream the sidecar ends early instead
        terminates with one StreamErrorFrame and no [DONE].
      format: binary
      type: string
      x-sse-events:
        message:
          $ref: '#/components/schemas/ChatCompletionStreamData'
        sentinel: '[DONE]'
        terminal_error:
          $ref: '#/components/schemas/StreamErrorFrame'
    AccessControlExposeHeaders:
      description: >-
        The response headers a browser client may read, as a comma-separated
        list; it names x-request-id, Retry-After and Server-Timing when the
        response carries them.
      maxLength: 1024
      minLength: 1
      type: string
    ServerTiming:
      description: >-
        W3C Server-Timing. As a HEADER it carries pre-stream phases only, for
        example the gateway's authorize call and the sidecar's ra-queue (time
        waiting for a seat) and ra-admit (the sidecar's own work before the
        request reached the model). Time to first token is never in the header,
        because it is not known when the headers are sent; on a streaming
        response it arrives as a Server-Timing TRAILER named ra-ttft, after the
        last SSE frame. Metric names are not a closed set: ignore a name you do
        not know, and treat the trailer as optional.
      maxLength: 1024
      minLength: 1
      type: string
    ChatMessage:
      discriminator:
        propertyName: role
      oneOf:
        - $ref: '#/components/schemas/SystemMessage'
        - $ref: '#/components/schemas/UserMessage'
        - $ref: '#/components/schemas/AssistantMessage'
        - $ref: '#/components/schemas/ToolMessage'
    ModelId:
      description: An explicitly entitled Wally model identifier.
      maxLength: 128
      minLength: 1
      pattern: ^[A-Za-z0-9][A-Za-z0-9._:/-]*$
      type: string
    ReasoningEffort:
      enum:
        - none
        - minimal
        - low
        - medium
        - high
      type: string
    ResponseFormat:
      additionalProperties: false
      properties:
        type:
          enum:
            - text
            - json_object
          type: string
      required:
        - type
      type: object
    StopSequenceSet:
      oneOf:
        - $ref: '#/components/schemas/StopSequence'
        - $ref: '#/components/schemas/StopSequenceList'
    StreamOptions:
      additionalProperties: false
      properties:
        include_usage:
          type: boolean
      required:
        - include_usage
      type: object
    ToolChoice:
      oneOf:
        - $ref: '#/components/schemas/ToolChoiceMode'
        - $ref: '#/components/schemas/NamedToolChoice'
    ChatTool:
      additionalProperties: false
      properties:
        function:
          $ref: '#/components/schemas/ChatToolFunction'
        type:
          const: function
      required:
        - type
        - function
      type: object
    EndUserId:
      maxLength: 256
      minLength: 1
      type: string
    CompletionChoice:
      additionalProperties: false
      properties:
        finish_reason:
          $ref: '#/components/schemas/CompletionFinishReason'
        index:
          minimum: 0
          type: integer
        logprobs:
          type: 'null'
        matched_stop:
          anyOf:
            - $ref: '#/components/schemas/CompletionText'
            - maximum: 2147483647
              minimum: 0
              type: integer
            - type: 'null'
        message:
          $ref: '#/components/schemas/CompletionMessage'
      required:
        - index
        - message
        - finish_reason
      type: object
    CompletionId:
      maxLength: 256
      minLength: 1
      type: string
    CompletionMetadata:
      additionalProperties: false
      properties:
        weight_version:
          $ref: '#/components/schemas/CompletionWeightVersion'
        weight_versions:
          description: >-
            Every weight range the engine has loaded. Served alongside
            weight_version, which names the active one.
          items:
            $ref: '#/components/schemas/CompletionWeightVersionRange'
          maxItems: 64
          type: array
      type: object
    CompletionModelId:
      maxLength: 128
      minLength: 1
      type: string
    CompletionSystemFingerprint:
      maxLength: 120
      minLength: 1
      type: string
    CompletionUsage:
      additionalProperties: false
      properties:
        completion_tokens:
          minimum: 0
          type: integer
        completion_tokens_details:
          anyOf:
            - $ref: '#/components/schemas/CompletionTokensDetails'
            - type: 'null'
        prompt_tokens:
          minimum: 0
          type: integer
        prompt_tokens_details:
          anyOf:
            - $ref: '#/components/schemas/CompletionPromptTokensDetails'
            - type: 'null'
        reasoning_tokens:
          minimum: 0
          type: integer
        total_tokens:
          minimum: 0
          type: integer
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      type: object
    OpenAIError:
      additionalProperties: false
      properties:
        error:
          $ref: '#/components/schemas/OpenAIErrorDetail'
      required:
        - error
      type: object
    RequestId:
      maxLength: 256
      minLength: 1
      type: string
    RetryAfterSeconds:
      minimum: 0
      type: integer
    SystemMessage:
      additionalProperties: false
      properties:
        content:
          $ref: '#/components/schemas/NonEmptyText'
        name:
          $ref: '#/components/schemas/ToolName'
        role:
          const: system
      required:
        - role
        - content
      type: object
    UserMessage:
      additionalProperties: false
      properties:
        content:
          $ref: '#/components/schemas/UserContent'
        name:
          $ref: '#/components/schemas/ToolName'
        role:
          const: user
      required:
        - role
        - content
      type: object
    AssistantMessage:
      additionalProperties: false
      anyOf:
        - required:
            - content
        - required:
            - tool_calls
      properties:
        content:
          anyOf:
            - $ref: '#/components/schemas/FreeText'
            - type: 'null'
        name:
          $ref: '#/components/schemas/ToolName'
        reasoning_content:
          anyOf:
            - $ref: '#/components/schemas/FreeText'
            - type: 'null'
        role:
          const: assistant
        tool_calls:
          items:
            $ref: '#/components/schemas/AssistantToolCall'
          maxItems: 128
          minItems: 1
          type: array
      required:
        - role
      type: object
    ToolMessage:
      additionalProperties: false
      properties:
        content:
          $ref: '#/components/schemas/FreeText'
        role:
          const: tool
        tool_call_id:
          $ref: '#/components/schemas/ToolCallId'
      required:
        - role
        - content
        - tool_call_id
      type: object
    StopSequence:
      maxLength: 4096
      minLength: 1
      type: string
    StopSequenceList:
      items:
        $ref: '#/components/schemas/StopSequence'
      maxItems: 4
      minItems: 1
      type: array
    ToolChoiceMode:
      enum:
        - none
        - auto
        - required
      type: string
    NamedToolChoice:
      additionalProperties: false
      properties:
        function:
          $ref: '#/components/schemas/NamedToolChoiceFunction'
        type:
          const: function
      required:
        - type
        - function
      type: object
    ChatToolFunction:
      additionalProperties: false
      properties:
        description:
          $ref: '#/components/schemas/FreeText'
        name:
          $ref: '#/components/schemas/ToolName'
        parameters:
          $ref: '#/components/schemas/ToolParameters'
        strict:
          type: boolean
      required:
        - name
        - parameters
      type: object
    CompletionFinishReason:
      enum:
        - stop
        - length
        - tool_calls
        - content_filter
        - function_call
      type: string
    CompletionText:
      maxLength: 16777216
      minLength: 0
      type: string
    CompletionMessage:
      additionalProperties: false
      properties:
        content:
          anyOf:
            - $ref: '#/components/schemas/CompletionText'
            - type: 'null'
        reasoning_content:
          anyOf:
            - $ref: '#/components/schemas/CompletionText'
            - type: 'null'
        role:
          $ref: '#/components/schemas/CompletionRole'
        tool_calls:
          anyOf:
            - items:
                $ref: '#/components/schemas/CompletionToolCall'
              maxItems: 128
              minItems: 1
              type: array
            - type: 'null'
      required:
        - role
        - content
      type: object
    CompletionWeightVersion:
      maxLength: 256
      minLength: 1
      type: string
    CompletionWeightVersionRange:
      additionalProperties: false
      description: One loaded weight range, as the engine reports it.
      properties:
        end:
          minimum: 0
          type: integer
        start:
          minimum: 0
          type: integer
        version:
          $ref: '#/components/schemas/CompletionWeightVersion'
      required:
        - version
        - start
        - end
      type: object
    CompletionTokensDetails:
      additionalProperties: false
      minProperties: 1
      properties:
        accepted_prediction_tokens:
          minimum: 0
          type: integer
        audio_tokens:
          minimum: 0
          type: integer
        reasoning_tokens:
          minimum: 0
          type: integer
        rejected_prediction_tokens:
          minimum: 0
          type: integer
        text_tokens:
          minimum: 0
          type: integer
      type: object
    CompletionPromptTokensDetails:
      additionalProperties: false
      minProperties: 1
      properties:
        audio_tokens:
          minimum: 0
          type: integer
        cached_tokens:
          minimum: 0
          type: integer
        text_tokens:
          minimum: 0
          type: integer
      type: object
    OpenAIErrorDetail:
      additionalProperties: false
      properties:
        code:
          anyOf:
            - $ref: '#/components/schemas/ErrorCode'
            - type: 'null'
        message:
          $ref: '#/components/schemas/ErrorMessage'
        param:
          anyOf:
            - $ref: '#/components/schemas/ErrorParameter'
            - type: 'null'
        type:
          $ref: '#/components/schemas/ErrorType'
      required:
        - message
        - type
      type: object
    NonEmptyText:
      maxLength: 16777216
      minLength: 1
      type: string
    ToolName:
      maxLength: 64
      minLength: 1
      pattern: ^[A-Za-z0-9_-]+$
      type: string
    UserContent:
      oneOf:
        - $ref: '#/components/schemas/NonEmptyText'
        - $ref: '#/components/schemas/ContentPartList'
    FreeText:
      maxLength: 16777216
      minLength: 0
      type: string
    AssistantToolCall:
      additionalProperties: false
      properties:
        function:
          $ref: '#/components/schemas/AssistantToolCallFunction'
        id:
          $ref: '#/components/schemas/ToolCallId'
        type:
          const: function
      required:
        - id
        - type
        - function
      type: object
    ToolCallId:
      maxLength: 256
      minLength: 1
      type: string
    NamedToolChoiceFunction:
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/ToolName'
      required:
        - name
      type: object
    ToolParameters:
      additionalProperties: false
      properties:
        $schema:
          $ref: '#/components/schemas/JsonSchemaDialect'
        additionalProperties:
          $ref: '#/components/schemas/AdditionalPropertiesRule'
        properties:
          $ref: '#/components/schemas/ToolParameterProperties'
        required:
          items:
            $ref: '#/components/schemas/ToolParameterName'
          type: array
          uniqueItems: true
        type:
          const: object
      required:
        - type
        - properties
      type: object
    CompletionRole:
      enum:
        - assistant
      type: string
    CompletionToolCall:
      additionalProperties: false
      properties:
        function:
          $ref: '#/components/schemas/CompletionToolFunction'
        id:
          $ref: '#/components/schemas/CompletionToolCallId'
        index:
          description: >-
            Position of this call within the message's tool_calls array. Emitted
            by the engine on buffered and streamed responses alike. NOT
            required: a provider-hosted model routed through the gateway may
            omit it.
          maximum: 127
          minimum: 0
          type: integer
        type:
          const: function
      required:
        - id
        - type
        - function
      type: object
    ErrorCode:
      enum:
        - bad_request
        - not_found
        - payload_too_large
        - unprocessable
        - invalid_api_key
        - expired_api_key
        - revoked_api_key
        - insufficient_credit
        - account_frozen
        - model_not_entitled
        - not_in_cohort
        - user_rate_limited
        - request_cancelled
        - quota_exceeded
        - capacity_exceeded
        - idempotency_key_reused
        - unsupported_endpoint
        - proxy_retired
        - gateway_unavailable
        - control_plane_overloaded
        - credit_gate_unavailable
        - upstream_contract_violation
        - unattributed_key
        - internal
        - bad_gateway
        - draining
        - spool_unhealthy
        - cold
        - timeout
      type: string
    ErrorMessage:
      maxLength: 2048
      minLength: 1
      type: string
    ErrorParameter:
      maxLength: 256
      minLength: 1
      type: string
    ErrorType:
      enum:
        - invalid_request_error
        - authentication_error
        - permission_error
        - rate_limit_error
        - quota
        - capacity
        - server_error
        - timeout
      type: string
    ContentPartList:
      items:
        $ref: '#/components/schemas/ContentPart'
      maxItems: 4096
      minItems: 1
      type: array
    AssistantToolCallFunction:
      additionalProperties: false
      properties:
        arguments:
          $ref: '#/components/schemas/FreeText'
        name:
          $ref: '#/components/schemas/ToolName'
      required:
        - name
        - arguments
      type: object
    JsonSchemaDialect:
      description: >-
        The JSON Schema dialect a client's tool-schema generator stamps at the
        ROOT of `parameters` (zod-to-json-schema, the Vercel AI SDK and Pydantic
        all emit `$schema`). Accepted at the root only, only as a
        json-schema.org URI, and otherwise ignored: `parameters` is validated
        against this contract, not against the dialect named.
      format: uri
      maxLength: 256
      minLength: 1
      pattern: ^https?://json-schema\.org/
      type: string
    AdditionalPropertiesRule:
      oneOf:
        - type: boolean
        - $ref: '#/components/schemas/JsonSchemaProperty'
    ToolParameterProperties:
      additionalProperties:
        $ref: '#/components/schemas/JsonSchemaProperty'
      description: >-
        OpenAI tool parameter names are caller-defined; each value is still a
        typed JSON Schema property.
      type: object
    ToolParameterName:
      maxLength: 256
      minLength: 1
      type: string
    CompletionToolFunction:
      additionalProperties: false
      properties:
        arguments:
          $ref: '#/components/schemas/CompletionText'
        name:
          $ref: '#/components/schemas/CompletionToolName'
      required:
        - name
        - arguments
      type: object
    CompletionToolCallId:
      maxLength: 256
      minLength: 1
      type: string
    ContentPart:
      discriminator:
        propertyName: type
      oneOf:
        - $ref: '#/components/schemas/TextContentPart'
        - $ref: '#/components/schemas/ImageContentPart'
    JsonSchemaProperty:
      additionalProperties: false
      properties:
        additionalProperties:
          $ref: '#/components/schemas/AdditionalPropertiesRule'
        allOf:
          items:
            $ref: '#/components/schemas/JsonSchemaProperty'
          minItems: 1
          type: array
        anyOf:
          items:
            $ref: '#/components/schemas/JsonSchemaProperty'
          minItems: 1
          type: array
        const:
          $ref: '#/components/schemas/JsonScalar'
        default:
          $ref: '#/components/schemas/JsonScalar'
        description:
          $ref: '#/components/schemas/FreeText'
        enum:
          items:
            $ref: '#/components/schemas/JsonScalar'
          minItems: 1
          type: array
        items:
          $ref: '#/components/schemas/JsonSchemaProperty'
        maxLength:
          minimum: 0
          type: integer
        maximum:
          maximum: 1e+308
          minimum: -1e+308
          type: number
        minLength:
          minimum: 0
          type: integer
        minimum:
          maximum: 1e+308
          minimum: -1e+308
          type: number
        oneOf:
          items:
            $ref: '#/components/schemas/JsonSchemaProperty'
          minItems: 1
          type: array
        pattern:
          maxLength: 1024
          minLength: 1
          type: string
        properties:
          $ref: '#/components/schemas/ToolParameterProperties'
        required:
          items:
            $ref: '#/components/schemas/ToolParameterName'
          type: array
          uniqueItems: true
        type:
          $ref: '#/components/schemas/JsonSchemaType'
      type: object
    CompletionToolName:
      maxLength: 64
      minLength: 1
      pattern: ^[A-Za-z0-9_-]+$
      type: string
    TextContentPart:
      additionalProperties: false
      properties:
        text:
          $ref: '#/components/schemas/NonEmptyText'
        type:
          const: text
      required:
        - type
        - text
      type: object
    ImageContentPart:
      additionalProperties: false
      properties:
        image_url:
          $ref: '#/components/schemas/ImageUrl'
        type:
          const: image_url
      required:
        - type
        - image_url
      type: object
    JsonScalar:
      oneOf:
        - $ref: '#/components/schemas/FreeText'
        - maximum: 1e+308
          minimum: -1e+308
          type: number
        - maximum: 9007199254740991
          minimum: -9007199254740991
          type: integer
        - type: boolean
        - type: 'null'
    JsonSchemaType:
      enum:
        - string
        - number
        - integer
        - boolean
        - array
        - object
        - 'null'
      type: string
    ImageUrl:
      additionalProperties: false
      properties:
        detail:
          enum:
            - auto
            - low
            - high
          type: string
        url:
          description: An https URL or an RFC 2397 data URL.
          maxLength: 16777216
          minLength: 1
          type: string
      required:
        - url
      type: object
  responses:
    Error:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OpenAIError'
      description: OpenAI-shaped error; raw upstream bodies are never returned
      headers:
        x-request-id:
          description: Request correlation id
          schema:
            $ref: '#/components/schemas/RequestId'
    Unauthorized:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OpenAIError'
      description: Missing, malformed, or unknown Cloud key
      headers:
        x-request-id:
          description: Request correlation id
          schema:
            $ref: '#/components/schemas/RequestId'
    Forbidden:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OpenAIError'
      description: Key is valid but the model or route is not entitled
      headers:
        x-request-id:
          description: Request correlation id
          schema:
            $ref: '#/components/schemas/RequestId'
    RateLimited:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OpenAIError'
      description: Entitlement or GPU admission capacity limit
      headers:
        Access-Control-Expose-Headers:
          description: Response headers a browser client may read
          schema:
            $ref: '#/components/schemas/AccessControlExposeHeaders'
        Retry-After:
          description: Seconds before retrying when supplied
          schema:
            $ref: '#/components/schemas/RetryAfterSeconds'
        Server-Timing:
          description: Pre-stream phase timings when supplied
          schema:
            $ref: '#/components/schemas/ServerTiming'
        x-request-id:
          description: Request correlation id
          schema:
            $ref: '#/components/schemas/RequestId'
  securitySchemes:
    BearerAuth:
      bearerFormat: RunAnywhereCloudKey
      scheme: bearer
      type: http

````