LLM Gateway

Chat Completions

Create OpenAI-compatible chat completions through LLM Gateway. Route requests to any supported model across OpenAI, Anthropic, Google, and 20+ providers.

Create a completion for the chat conversation

POST
/v1/chat/completions

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication using API keys

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

curl -X POST "https://api.llmgateway.io/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-5",    "messages": [      {        "role": "user"      }    ]  }'
{
  "id": "string",
  "object": "string",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "string",
        "content": "string",
        "reasoning": "string",
        "tool_calls": [
          {
            "id": "string",
            "type": "function",
            "function": {
              "name": "string",
              "arguments": "string"
            }
          }
        ],
        "images": [
          {
            "type": "image_url",
            "image_url": {
              "url": "string"
            }
          }
        ]
      },
      "finish_reason": "string"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "reasoning_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0,
      "cache_creation_tokens": 0,
      "cache_creation": {
        "ephemeral_5m_input_tokens": 0,
        "ephemeral_1h_input_tokens": 0
      },
      "audio_tokens": 0,
      "video_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "cost": 0,
    "cost_details": {
      "upstream_inference_cost": 0,
      "upstream_inference_prompt_cost": 0,
      "upstream_inference_completions_cost": 0,
      "total_cost": 0,
      "input_cost": 0,
      "output_cost": 0,
      "cached_input_cost": 0,
      "cache_write_input_cost": 0,
      "request_cost": 0,
      "web_search_cost": 0,
      "image_input_cost": 0,
      "image_output_cost": 0,
      "audio_input_cost": 0,
      "data_storage_cost": 0
    },
    "info": "string"
  },
  "metadata": {
    "request_id": "string",
    "requested_model": "string",
    "requested_provider": "string",
    "used_model": "string",
    "used_provider": "string",
    "used_region": "string",
    "underlying_used_model": "string",
    "routing": [
      {
        "provider": "string",
        "model": "string",
        "region": "string",
        "status_code": 0,
        "error_type": "string",
        "succeeded": true,
        "apiKeyHash": "string",
        "logId": "string"
      }
    ]
  }
}
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}

How is this guide?

Last updated on