{"openapi":"3.0.0","info":{"description":"Unified AI API proxy supporting OpenAI and Anthropic compatible endpoints for multiple frontier models","version":[{"name":"v1","value":"v1"}]},"servers":[{"description":"Unified AI API proxy supporting OpenAI and Anthropic compatible endpoints for multiple frontier models","url":"https://api.apirails.com/bai"}],"paths":{"/v1/models":{"get":{"tags":["Models"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://docs.b.ai/llmservice/api/#1-list-models","api_endpoint":"https://api.b.ai/v1/models"},"summary":"List models","description":"List available models. Returns model IDs, ownership, and supported endpoint types.","security":[{"bearerAuth":[]}]}},"/v1/chat/completions":{"post":{"tags":["Chat"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://docs.b.ai/llmservice/api/#2-chat-completions-openai-compatible","api_endpoint":"https://api.b.ai/v1/chat/completions"},"summary":"Create chat completion (OpenAI compatible)","description":"Create a chat completion using OpenAI-compatible format. Supports streaming (SSE), tool calling, and web search.","security":[{"bearerAuth":[]}],"requestBody":{"description":"","required":true,"content":{"application/json":{"schema":{"type":"object","required":[],"properties":{"model":{"type":"string","description":"ID of the model to use (e.g. gpt-5.2). Claude models accept hyphenated aliases such as claude-sonnet-4-6","required":true},"messages":{"type":"array","description":"List of messages in the conversation. Roles: system, user, assistant, tool","required":true,"items":{"type":"object","properties":{"role":{"type":"string","description":"Message role","required":true,"enum":["system","user","assistant","tool"]},"content":{"type":"string","description":"Message content text","required":true},"name":{"type":"string","description":"Optional name for the message author"},"tool_call_id":{"type":"string","description":"When role is tool, the ID of the tool call this result is for"}}}},"stream":{"type":"boolean","description":"If true, partial message deltas will be sent as server-sent events","enum":[true,false]},"max_tokens":{"type":"number","description":"Maximum number of tokens that can be generated in the completion"},"temperature":{"type":"number","description":"Sampling temperature between 0 and 2. Higher values make output more random"},"top_p":{"type":"number","description":"Nucleus sampling: consider tokens with top_p probability mass"},"stop":{"type":"array","description":"Up to 4 sequences where the API will stop generating","items":{"type":"string"}},"n":{"type":"number","description":"How many chat completion choices to generate"},"frequency_penalty":{"type":"number","description":"Penalize repeated tokens. Between -2.0 and 2.0"},"presence_penalty":{"type":"number","description":"Penalize tokens that appear in the text so far. Between -2.0 and 2.0"},"seed":{"type":"number","description":"Random seed for deterministic sampling (if supported by model)"},"user":{"type":"string","description":"Optional end-user identifier for abuse monitoring"}}},"example":{"model":["gpt-5.2","claude-sonnet-4-6"],"messages":[[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"Hello"}]],"stream":[false],"max_tokens":[1024],"temperature":[1],"top_p":[1],"stop":[["\n","Human:"]],"n":[1],"frequency_penalty":[0],"presence_penalty":[0],"seed":[42],"user":["user-123"]}}}}}},"/v1/messages":{"post":{"tags":["Chat"],"parameters":[],"responses":{"401":{"description":"Bearer token required (Authorization header)","content":{"application/json":{}}}},"externalDocs":{"api_ref":"https://docs.b.ai/llmservice/api/#3-messages-claude-compatible","api_endpoint":"https://api.b.ai/v1/messages"},"summary":"Create message (Claude compatible)","description":"Create a message completion using Claude/Anthropic-compatible format. Supports streaming (SSE), tool use, and extended thinking.","security":[{"bearerAuth":[]}],"requestBody":{"description":"","required":true,"content":{"application/json":{"schema":{"type":"object","required":[],"properties":{"model":{"type":"string","description":"ID of the model. Claude models accept hyphenated aliases (e.g. claude-sonnet-4-6, claude-opus-4-6, claude-haiku-4-5)","required":true},"max_tokens":{"type":"number","description":"Maximum number of tokens to generate. Different models have different maximum values","required":true},"messages":{"type":"array","description":"Input messages. Alternating user/assistant turns. Limit: 100,000 messages","required":true,"items":{"type":"object","properties":{"role":{"type":"string","description":"Message role (user or assistant; use top-level system parameter for system prompts)","required":true,"enum":["user","assistant"]},"content":{"type":"string","description":"Text string or array of content blocks (text, image, tool_use, tool_result)","required":true}}}},"system":{"type":"string","description":"System prompt. Can be a plain string or an array of text blocks (for cache_control)"},"stream":{"type":"boolean","description":"Whether to stream the response using SSE","enum":[true,false]},"temperature":{"type":"number","description":"Randomness (0.0 - 1.0). Use ~0.0 for analytical tasks, ~1.0 for creative tasks"},"top_p":{"type":"number","description":"Nucleus sampling"},"top_k":{"type":"number","description":"Only sample from the top K options. Default disabled"},"stop_sequences":{"type":"array","description":"Custom text sequences that cause the model to stop generating","items":{"type":"string"}},"metadata":{"type":"object","description":"Request metadata. Supports user_id (opaque identifier)","properties":{"user_id":{"type":"string","description":"Opaque end-user identifier"}}}}},"example":{"model":["claude-sonnet-4-6","claude-opus-4-6"],"max_tokens":[1024],"messages":[[{"role":"user","content":"Hello, Claude!"}]],"system":["You are a helpful assistant."],"stream":[false],"temperature":[1],"top_p":[1],"top_k":[40],"stop_sequences":[["\n\nHuman:"]],"metadata":[{"user_id":"user-123"}]}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"security":[{"bearerAuth":[]}]}