{"openapi":"3.0.0","info":{"description":"Token Harbor AI gateway — one Universal Key (thk_live-...) and one balance for 700+ models from every major provider (Anthropic, OpenAI, Google, DeepSeek, Qwen, Z.AI, MiniMax, Mistral, xAI, Moonshot, Meta). OpenAI-compatible /v1 and Anthropic-compatible /v1/messages; smart routing (th-orchestra), exact/semantic prompt caching, per-token passthrough pricing.","version":"v1"},"servers":[{"description":"Token Harbor AI gateway — one Universal Key (thk_live-...) and one balance for 700+ models from every major provider (Anthropic, OpenAI, Google, DeepSeek, Qwen, Z.AI, MiniMax, Mistral, xAI, Moonshot, Meta). OpenAI-compatible /v1 and Anthropic-compatible /v1/messages; smart routing (th-orchestra), exact/semantic prompt caching, per-token passthrough pricing.","url":"https://api.apirails.com/tokenharbor"}],"paths":{"/models":{"get":{"tags":["Models"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://tokenharbor.ai/docs/api/models","api_endpoint":"https://tokenharbor.ai/v1/models"},"summary":"List models","description":"Returns the live model catalog as JSON — same data as the /models page: ids, per-million input/output pricing, capabilities. Model ids ending in :free never charge the balance.","security":[{"bearerAuth":[]}]}},"/chat/completions":{"post":{"tags":["Chat"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://tokenharbor.ai/docs/api/curl","api_endpoint":"https://tokenharbor.ai/v1/chat/completions"},"summary":"Create chat completion","description":"OpenAI-compatible chat completions. Any id from /models works (th-orchestra smart routing, tokenharbor/*, anthropic/*, openai/*, deepseek-v4-flash, ...). stream:true emits Server-Sent Events. Responses carry X-TH-Steering-Applied and, when cached, X-TH-Cache-Layer headers.","security":[{"bearerAuth":[]}],"requestBody":{"description":"","required":true,"content":{"application/json":{"schema":{"type":"object","required":[],"properties":{"max_tokens":{"type":"number","description":"Maximum number of tokens to generate."},"messages":{"type":"array","description":"Array of message objects with role and content. Content arrays with image parts are routed to models that accept the input type.","required":true,"items":{"type":"object","properties":{"content":{"type":"string","description":"The contents of the message. String, or an array of content parts (text / image_url with base64 data URLs for vision models).","required":true},"role":{"type":"string","description":"The role of the message author.","required":true,"enum":["system","user","assistant"]}}}},"model":{"type":"string","description":"Model id from /models. th-orchestra enables plan/build/review smart routing for tool-using agents; ids ending in :free never charge the balance.","required":true},"stream":{"type":"boolean","description":"Stream tokens as they're generated via server-sent events.","enum":[true,false]},"temperature":{"type":"number","description":"Controls randomness. Higher values increase randomness; lower values make output more deterministic."},"th_steering":{"type":"string","description":"Set to \"off\" for pure routing with an untouched prompt (same as the X-TH-Steering header). Only relevant for th-orchestra.","enum":["off"]},"tool_choice":{"type":"string","description":"Controls tool use: auto, required, none, or a specific tool.","enum":["auto","required","none"]},"tools":{"type":"array","description":"Tool/function definitions. Sending a tools array engages th-orchestra's plan -> build -> review routing for agent clients.","items":{"type":"object","properties":{"type":{"type":"string","description":"The tool type, currently function.","required":true,"enum":["function"]},"function":{"type":"object","description":"The function definition (name, description, parameters as JSON Schema).","required":true}}}},"top_p":{"type":"number","description":"Nucleus sampling: consider only tokens with top_p probability mass."}}},"example":{"max_tokens":1024,"messages":[{"content":"What is the capital of New York?","role":"user"}],"model":"th-orchestra","stream":"","temperature":0.7,"th_steering":"off","tool_choice":"auto","tools":[],"top_p":1}}}}}},"/messages":{"post":{"tags":["Chat"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://tokenharbor.ai/docs/api/curl","api_endpoint":"https://tokenharbor.ai/v1/messages"},"summary":"Create message","description":"Anthropic Messages API shape (point the official Anthropic SDK at base URL https://tokenharbor.ai). Auth accepts Authorization: Bearer or x-api-key. Same router, same bill as /v1/chat/completions; every gateway model id works. max_tokens is required by the Anthropic schema.","security":[{"bearerAuth":[]}],"requestBody":{"description":"","required":true,"content":{"application/json":{"schema":{"type":"object","required":[],"properties":{"max_tokens":{"type":"number","description":"Maximum number of tokens to generate. Required by the Anthropic schema.","required":true},"messages":{"type":"array","description":"Array of message objects with role and content.","required":true,"items":{"type":"object","properties":{"content":{"type":"string","description":"The contents of the message.","required":true},"role":{"type":"string","description":"The role of the message author.","required":true,"enum":["user","assistant"]}}}},"model":{"type":"string","description":"Model id from /models (any gateway model, e.g. tokenharbor/qwen3-max or th-orchestra).","required":true},"stream":{"type":"boolean","description":"Stream typed events (message_start, content_block_delta, message_stop) matching the Anthropic SDK event stream.","enum":[true,false]},"system":{"type":"string","description":"System prompt. Forwarded byte-for-byte when a specific model id is used."},"temperature":{"type":"number","description":"Controls randomness. Higher values increase randomness; lower values make output more deterministic."},"tools":{"type":"array","description":"Tool definitions (Anthropic schema). Engages th-orchestra's plan -> build -> review routing for agent clients.","items":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the tool does."},"input_schema":{"type":"object","description":"JSON Schema describing the tool's input parameters.","required":true},"name":{"type":"string","description":"The name of the tool.","required":true}}}},"top_p":{"type":"number","description":"Nucleus sampling: consider only tokens with top_p probability mass."}}},"example":{"max_tokens":1024,"messages":[{"content":"What is the capital of New York?","role":"user"}],"model":"tokenharbor/qwen3-max","stream":"","system":"You are a concise assistant.","temperature":0.7,"tools":[],"top_p":1}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"security":[{"bearerAuth":[]}]}