plaingateway
API reference

Chat completions

Create a chat completion or stream.

POST /chat/completions accepts model as a string, messages as an array, and optional stream, tools, tool_choice, response_format, reasoning, provider, models, and usage. The gateway preserves the OpenAI response shape and adds usage.cost, plaingateway only.

Request

http
POST https://plaingateway.com/api/v1/chat/completions
Authorization: Bearer sk-pg-v1-...
Content-Type: application/json

{
  "model": "openai/gpt-5.6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Say hello in five words."
    }
  ],
  "max_tokens": 32
}

Response

http
HTTP/1.1 200
{
  "id": "gen-SCRUBBED-1",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "openai/gpt-5.6-luna",
  "provider": "OpenAI",
  "system_fingerprint": null,
  "service_tier": "default",
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "completed",
      "message": {
        "role": "assistant",
        "content": "Hello! How are you today?",
        "refusal": null,
        "reasoning": null
      }
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 11,
    "total_tokens": 23,
    "cost": 1.56e-05,
    "is_byok": false,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    },
    "cost_details": {
      "upstream_inference_cost": 1.56e-05,
      "upstream_inference_prompt_cost": 2.4e-06,
      "upstream_inference_completions_cost": 1.32e-05
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "image_tokens": 0,
      "audio_tokens": 0
    }
  }
}

OpenRouter-compatible request fields

Parameter Type Semantics
model string Primary model ID.
models string[] Fallback model IDs after model, or the only IDs if model is absent.
messages object[] Conversation turns for chat or Messages.
prompt string Legacy completions input.
input string or object[] Responses input.
stream boolean Return server-sent events.
tools object[] Available function tools.
tool_choice string or object Select tool use.
response_format object Request a structured output format.
reasoning object effort, max_tokens, and exclude reasoning controls.
usage.include boolean Ask for usage; plaingateway always includes usage and adds cost.
provider.order string[] Try named providers first.
provider.only string[] Keep named providers only.
provider.ignore string[] Exclude named providers.
provider.sort string or object Sort by price, throughput, or latency.
provider.allow_fallbacks boolean With false, try only the ordered list or first host.
provider.data_collection string deny excludes collecting hosts.
provider.zdr boolean true keeps zero retention hosts.
provider.quantizations string[] Keep matching quantizations.
provider.max_price object prompt and completion ceilings in USD per 1M tokens.
HTTP-Referer string header App URL for attribution.
X-OpenRouter-Title string header App name for attribution.
X-Title string header Also accepted for app attribution, plaingateway only.

Host pinning, usage.cost, X-PG-Host, X-PG-Cost-USD, and X-PG-Request-Id are plaingateway only.