{
    "openapi": "3.0.3",
    "info": {
        "title": "Bifrost HTTP Transport API",
        "description": "A unified HTTP API for accessing multiple AI model providers:\n\n• openai\n• anthropic\n• azure\n• bedrock\n• cohere\n• vertex\n• mistral\n• ollama\n• groq\n• sgl\n\nBifrost provides:\n\n**Core Features:**\n• Standardized **OpenAI Compatible** endpoints for text and chat completions\n• Built-in fallback support across providers\n• Comprehensive monitoring and logging\n• Real-time WebSocket streaming\n\n**MCP Integration:**\n• Model Context Protocol (MCP) support for external tool integration\n• Dynamic MCP client management (add/remove/edit clients)\n• STDIO, HTTP, and SSE connection types\n• Automatic tool discovery and execution\n\n**Management APIs:**\n• Provider configuration management (CRUD operations)\n• System configuration hot-reloading\n• Application logs with advanced filtering\n• Dropped request monitoring\n\n**Integration Endpoints:**\n• OpenAI-compatible: `/openai/chat/completions`\n• Anthropic-compatible: `/anthropic/v1/messages`\n• Google Gemini-compatible: `/genai/v1beta/models/{model}`\n• LiteLLM-compatible: `/chat/completions`",
        "version": "1.1.2",
        "contact": {
            "name": "Bifrost API Support",
            "url": "https://github.com/maximhq/bifrost"
        },
        "license": {
            "name": "MIT",
            "url": "https://opensource.org/licenses/MIT"
        }
    },
    "servers": [
        {
            "url": "http://localhost:8080",
            "description": "Local development server"
        }
    ],
    "paths": {
        "/v1/chat/completions": {
            "post": {
                "summary": "Create Chat Completion",
                "description": "Creates a chat completion using conversational messages. Supports tool calling, image inputs, and multiple AI providers with automatic fallbacks.",
                "operationId": "createChatCompletion",
                "tags": ["Chat Completions"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ChatCompletionRequest"
                            },
                            "examples": {
                                "simple_chat": {
                                    "summary": "Simple chat message",
                                    "value": {
                                        "model": "openai/gpt-4o",
                                        "messages": [
                                            {
                                                "role": "user",
                                                "content": "Hello, how are you?"
                                            }
                                        ]
                                    }
                                },
                                "tool_calling": {
                                    "summary": "Chat with tool calling",
                                    "value": {
                                        "model": "openai/gpt-4o",
                                        "messages": [
                                            {
                                                "role": "user",
                                                "content": "What's the weather in San Francisco?"
                                            }
                                        ],
                                        "params": {
                                            "tools": [
                                                {
                                                    "type": "function",
                                                    "function": {
                                                        "name": "get_weather",
                                                        "description": "Get current weather for a location",
                                                        "parameters": {
                                                            "type": "object",
                                                            "properties": {
                                                                "location": {
                                                                    "type": "string",
                                                                    "description": "The city and state, e.g. San Francisco, CA"
                                                                }
                                                            },
                                                            "required": ["location"]
                                                        }
                                                    }
                                                }
                                            ],
                                            "tool_choice": {
                                                "type": "function",
                                                "function": {
                                                    "name": "get_weather"
                                                }
                                            }
                                        }
                                    }
                                },
                                "with_fallbacks": {
                                    "summary": "Chat with fallback providers",
                                    "value": {
                                        "model": "openai/gpt-4o",
                                        "messages": [
                                            {
                                                "role": "user",
                                                "content": "Explain quantum computing"
                                            }
                                        ],
                                        "fallbacks": [
                                            "anthropic/claude-3-sonnet-20240229",
                                            "cohere/command"
                                        ]
                                    }
                                },
                                "structured_content": {
                                    "summary": "Chat with structured content (text and image)",
                                    "value": {
                                        "model": "openai/gpt-4o",
                                        "messages": [
                                            {
                                                "role": "user",
                                                "content": [
                                                    {
                                                        "type": "text",
                                                        "text": "What's happening in this image? What's the weather like?"
                                                    },
                                                    {
                                                        "type": "image_url",
                                                        "image_url": {
                                                            "url": "https://example.com/weather-photo.jpg",
                                                            "detail": "high"
                                                        }
                                                    }
                                                ]
                                            }
                                        ],
                                        "params": {
                                            "max_tokens": 1000,
                                            "temperature": 0.7
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful chat completion",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostResponse"
                                },
                                "examples": {
                                    "simple_response": {
                                        "summary": "Simple chat response",
                                        "value": {
                                            "id": "chatcmpl-123",
                                            "object": "chat.completion",
                                            "choices": [
                                                {
                                                    "index": 0,
                                                    "message": {
                                                        "role": "assistant",
                                                        "content": "Hello! I'm doing well, thank you for asking. How can I help you today?"
                                                    },
                                                    "finish_reason": "stop"
                                                }
                                            ],
                                            "model": "gpt-4o",
                                            "created": 1677652288,
                                            "usage": {
                                                "prompt_tokens": 12,
                                                "completion_tokens": 19,
                                                "total_tokens": 31
                                            },
                                            "extra_fields": {
                                                "provider": "openai",
                                                "model_params": {},
                                                "latency": 1.234,
                                                "raw_response": {}
                                            }
                                        }
                                    },
                                    "tool_response": {
                                        "summary": "Tool calling response",
                                        "value": {
                                            "id": "chatcmpl-456",
                                            "object": "chat.completion",
                                            "choices": [
                                                {
                                                    "index": 0,
                                                    "message": {
                                                        "role": "assistant",
                                                        "content": null,
                                                        "tool_calls": [
                                                            {
                                                                "id": "call_123",
                                                                "type": "function",
                                                                "function": {
                                                                    "name": "get_weather",
                                                                    "arguments": "{\"location\": \"San Francisco, CA\"}"
                                                                }
                                                            }
                                                        ]
                                                    },
                                                    "finish_reason": "tool_calls"
                                                }
                                            ],
                                            "model": "gpt-4o",
                                            "created": 1677652288,
                                            "usage": {
                                                "prompt_tokens": 45,
                                                "completion_tokens": 12,
                                                "total_tokens": 57
                                            },
                                            "extra_fields": {
                                                "provider": "openai",
                                                "model_params": {},
                                                "latency": 0.856,
                                                "raw_response": {}
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/v1/text/completions": {
            "post": {
                "summary": "Create Text Completion",
                "description": "Creates a text completion from a prompt. Useful for text generation, summarization, and other non-conversational tasks.",
                "operationId": "createTextCompletion",
                "tags": ["Text Completions"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/TextCompletionRequest"
                            },
                            "examples": {
                                "simple_text": {
                                    "summary": "Simple text completion",
                                    "value": {
                                        "model": "anthropic/claude-2.1",
                                        "text": "The future of artificial intelligence is",
                                        "params": {
                                            "max_tokens": 100,
                                            "temperature": 0.7
                                        }
                                    }
                                },
                                "with_stop_sequences": {
                                    "summary": "Text completion with stop sequences",
                                    "value": {
                                        "provider": "anthropic",
                                        "model": "claude-2.1",
                                        "text": "Write a short story about a robot:",
                                        "params": {
                                            "max_tokens": 200,
                                            "temperature": 0.8,
                                            "stop_sequences": ["\n\n", "THE END"]
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful text completion",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostResponse"
                                },
                                "examples": {
                                    "text_response": {
                                        "summary": "Text completion response",
                                        "value": {
                                            "id": "cmpl-789",
                                            "object": "text.completion",
                                            "choices": [
                                                {
                                                    "index": 0,
                                                    "message": {
                                                        "role": "assistant",
                                                        "content": "The future of artificial intelligence is incredibly promising, with advances in machine learning, natural language processing, and robotics reshaping industries and daily life."
                                                    },
                                                    "finish_reason": "stop"
                                                }
                                            ],
                                            "model": "claude-2.1",
                                            "created": 1677652288,
                                            "usage": {
                                                "prompt_tokens": 8,
                                                "completion_tokens": 32,
                                                "total_tokens": 40
                                            },
                                            "extra_fields": {
                                                "provider": "anthropic",
                                                "model_params": {
                                                    "max_tokens": 100,
                                                    "temperature": 0.7
                                                },
                                                "latency": 0.654,
                                                "raw_response": {}
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/v1/mcp/tool/execute": {
            "post": {
                "summary": "Execute MCP Tool",
                "description": "Executes an MCP (Model Context Protocol) tool that has been configured in Bifrost. This endpoint is used to execute tool calls returned by AI models during conversations. Requires MCP to be configured in Bifrost.",
                "operationId": "executeMCPTool",
                "tags": ["MCP Tools"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ToolCall"
                            },
                            "examples": {
                                "google_search": {
                                    "summary": "Google Search Tool Execution",
                                    "value": {
                                        "type": "function",
                                        "id": "toolu_01VfefsSy7ZRdawdw7U2fg",
                                        "function": {
                                            "name": "google_search",
                                            "arguments": "{\"gl\":\"us\",\"hl\":\"en\",\"num\":5,\"q\":\"San Francisco news yesterday\",\"tbs\":\"qdr:d\"}"
                                        }
                                    }
                                },
                                "file_read": {
                                    "summary": "File Read Tool Execution",
                                    "value": {
                                        "type": "function",
                                        "id": "call_abc123",
                                        "function": {
                                            "name": "read_file",
                                            "arguments": "{\"path\": \"/tmp/config.json\"}"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Tool execution successful",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostMessage"
                                },
                                "examples": {
                                    "search_result": {
                                        "summary": "Google Search Result",
                                        "value": {
                                            "role": "tool",
                                            "content": "{\n  \"searchParameters\": {\n    \"q\": \"San Francisco news yesterday\",\n    \"gl\": \"us\",\n    \"hl\": \"en\",\n    \"type\": \"search\",\n    \"num\": 5,\n    \"tbs\": \"qdr:d\",\n    \"engine\": \"google\"\n  },\n  \"organic\": [\n    {\n      \"title\": \"San Francisco Chronicle · Giants' today\"\n    },\n    {\n      \"query\": \"s.f. chronicle e edition\"\n    }\n  ],\n  \"credits\": 1\n}",
                                            "tool_call_id": "toolu_01VfefsSy7ZRdawdw7U2fg"
                                        }
                                    },
                                    "file_content": {
                                        "summary": "File Read Result",
                                        "value": {
                                            "role": "tool",
                                            "content": "{\n  \"provider\": \"openai\",\n  \"model\": \"gpt-4o-mini\",\n  \"api_key\": \"sk-***\"\n}",
                                            "tool_call_id": "call_abc123"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/mcp/clients": {
            "get": {
                "summary": "List MCP Clients",
                "description": "Get information about all configured MCP (Model Context Protocol) clients including their connection state, available tools, and configuration.",
                "operationId": "listMCPClients",
                "tags": ["MCP Management"],
                "responses": {
                    "200": {
                        "description": "List of MCP clients",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/MCPClient"
                                    }
                                },
                                "examples": {
                                    "mcp_clients": {
                                        "summary": "MCP clients list",
                                        "value": [
                                            {
                                                "name": "filesystem",
                                                "config": {
                                                    "name": "filesystem",
                                                    "connection_type": "stdio",
                                                    "stdio_config": {
                                                        "command": "npx",
                                                        "args": [
                                                            "-y",
                                                            "@modelcontextprotocol/server-filesystem"
                                                        ]
                                                    },
                                                    "tools_to_execute": [
                                                        "read_file",
                                                        "list_directory"
                                                    ]
                                                },
                                                "tools": [
                                                    "read_file",
                                                    "list_directory",
                                                    "write_file"
                                                ],
                                                "state": "connected"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/mcp/client": {
            "post": {
                "summary": "Add MCP Client",
                "description": "Add a new MCP client configuration and establish connection. Supports STDIO, HTTP, and SSE connection types.",
                "operationId": "addMCPClient",
                "tags": ["MCP Management"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/MCPClientConfig"
                            },
                            "examples": {
                                "stdio_client": {
                                    "summary": "STDIO MCP Client",
                                    "value": {
                                        "name": "filesystem",
                                        "connection_type": "stdio",
                                        "stdio_config": {
                                            "command": "npx",
                                            "args": [
                                                "-y",
                                                "@modelcontextprotocol/server-filesystem"
                                            ],
                                            "envs": ["HOME"]
                                        },
                                        "tools_to_execute": ["read_file", "list_directory"]
                                    }
                                },
                                "http_client": {
                                    "summary": "HTTP MCP Client",
                                    "value": {
                                        "name": "remote-api",
                                        "connection_type": "http",
                                        "connection_string": "https://api.example.com/mcp"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "MCP client added successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/mcp/client/{name}": {
            "put": {
                "summary": "Edit MCP Client Tools",
                "description": "Modify which tools are available from an MCP client by updating tool filters.",
                "operationId": "editMCPClientTools",
                "tags": ["MCP Management"],
                "parameters": [
                    {
                        "name": "name",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Name of the MCP client to edit"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/MCPClientToolsEdit"
                            },
                            "examples": {
                                "whitelist_tools": {
                                    "summary": "Allow only specific tools",
                                    "value": {
                                        "tools_to_execute": ["read_file", "list_directory"]
                                    }
                                },
                                "blacklist_tools": {
                                    "summary": "Block dangerous tools",
                                    "value": {
                                        "tools_to_skip": ["delete_file", "write_file"]
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "MCP client tools updated successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            },
            "delete": {
                "summary": "Remove MCP Client",
                "description": "Remove an MCP client configuration and disconnect it from the system.",
                "operationId": "removeMCPClient",
                "tags": ["MCP Management"],
                "parameters": [
                    {
                        "name": "name",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Name of the MCP client to remove"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "MCP client removed successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/mcp/client/{name}/reconnect": {
            "post": {
                "summary": "Reconnect MCP Client",
                "description": "Reconnect a disconnected or errored MCP client.",
                "operationId": "reconnectMCPClient",
                "tags": ["MCP Management"],
                "parameters": [
                    {
                        "name": "name",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Name of the MCP client to reconnect"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "MCP client reconnected successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/providers": {
            "get": {
                "summary": "List Providers",
                "description": "Get a list of all configured AI providers with their settings and capabilities.",
                "operationId": "listProviders",
                "tags": ["Provider Management"],
                "responses": {
                    "200": {
                        "description": "List of providers",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ListProvidersResponse"
                                }
                            }
                        }
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            },
            "post": {
                "summary": "Add Provider",
                "description": "Add a new AI provider configuration with API keys, network settings, and concurrency options.",
                "operationId": "addProvider",
                "tags": ["Provider Management"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/AddProviderRequest"
                            },
                            "examples": {
                                "openai_provider": {
                                    "summary": "Add OpenAI Provider",
                                    "value": {
                                        "provider": "openai",
                                        "keys": [
                                            {
                                                "value": "env.OPENAI_API_KEY",
                                                "weight": 1,
                                                "models": ["gpt-4o", "gpt-4o-mini"]
                                            }
                                        ],
                                        "concurrency_and_buffer_size": {
                                            "concurrency": 10,
                                            "buffer_size": 100
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Provider added successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/providers/{provider}": {
            "get": {
                "summary": "Get Provider",
                "description": "Get detailed configuration for a specific AI provider.",
                "operationId": "getProvider",
                "tags": ["Provider Management"],
                "parameters": [
                    {
                        "name": "provider",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "$ref": "#/components/schemas/ModelProvider"
                        },
                        "description": "Provider name"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Provider configuration",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ProviderResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Provider not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostError"
                                }
                            }
                        }
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            },
            "put": {
                "summary": "Update Provider",
                "description": "Update an existing AI provider's configuration including API keys, network settings, and concurrency options.",
                "operationId": "updateProvider",
                "tags": ["Provider Management"],
                "parameters": [
                    {
                        "name": "provider",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "$ref": "#/components/schemas/ModelProvider"
                        },
                        "description": "Provider name"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/UpdateProviderRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Provider updated successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "404": {
                        "description": "Provider not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostError"
                                }
                            }
                        }
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            },
            "delete": {
                "summary": "Delete Provider",
                "description": "Remove an AI provider configuration from the system.",
                "operationId": "deleteProvider",
                "tags": ["Provider Management"],
                "parameters": [
                    {
                        "name": "provider",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "$ref": "#/components/schemas/ModelProvider"
                        },
                        "description": "Provider name"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Provider deleted successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Provider not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostError"
                                }
                            }
                        }
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/config": {
            "get": {
                "summary": "Get Configuration",
                "description": "Get the current system configuration including logging, pool size, and other runtime settings.",
                "operationId": "getConfig",
                "tags": ["Configuration"],
                "responses": {
                    "200": {
                        "description": "Current configuration",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClientConfig"
                                }
                            }
                        }
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            },
            "put": {
                "summary": "Update Configuration",
                "description": "Update system configuration settings. Supports hot-reloading of certain settings like drop_excess_requests.",
                "operationId": "updateConfig",
                "tags": ["Configuration"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ClientConfig"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Configuration updated successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SuccessResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/logs": {
            "get": {
                "summary": "Get Application Logs",
                "description": "Retrieve application logs with filtering, search, and pagination. Supports filtering by provider, model, status, time range, latency, tokens, and content search.",
                "operationId": "getLogs",
                "tags": ["Logging"],
                "parameters": [
                    {
                        "name": "providers",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Comma-separated list of providers to filter by"
                    },
                    {
                        "name": "models",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Comma-separated list of models to filter by"
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Comma-separated list of statuses to filter by (success, error)"
                    },
                    {
                        "name": "objects",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Comma-separated list of object types to filter by (chat.completion, text.completion)"
                    },
                    {
                        "name": "start_time",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date-time"
                        },
                        "description": "Start time for filtering (RFC3339 format)"
                    },
                    {
                        "name": "end_time",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date-time"
                        },
                        "description": "End time for filtering (RFC3339 format)"
                    },
                    {
                        "name": "min_latency",
                        "in": "query",
                        "schema": {
                            "type": "number"
                        },
                        "description": "Minimum latency in seconds"
                    },
                    {
                        "name": "max_latency",
                        "in": "query",
                        "schema": {
                            "type": "number"
                        },
                        "description": "Maximum latency in seconds"
                    },
                    {
                        "name": "min_tokens",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        },
                        "description": "Minimum token count"
                    },
                    {
                        "name": "max_tokens",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        },
                        "description": "Maximum token count"
                    },
                    {
                        "name": "content_search",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Search term for message content"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 1000,
                            "default": 50
                        },
                        "description": "Number of logs to return (1-1000)"
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "default": 0
                        },
                        "description": "Number of logs to skip"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Application logs",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LogSearchResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/api/logs/dropped": {
            "get": {
                "summary": "Get Dropped Requests",
                "description": "Get information about requests that were dropped due to queue overflow or other capacity limits.",
                "operationId": "getDroppedRequests",
                "tags": ["Logging"],
                "responses": {
                    "200": {
                        "description": "Dropped requests information",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DroppedRequestsResponse"
                                }
                            }
                        }
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/ws/logs": {
            "get": {
                "summary": "WebSocket Log Stream",
                "description": "Establish a WebSocket connection for real-time log streaming. Supports filtering similar to the /api/logs endpoint via query parameters.",
                "operationId": "logWebSocket",
                "tags": ["WebSocket"],
                "parameters": [
                    {
                        "name": "Upgrade",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "enum": ["websocket"]
                        }
                    },
                    {
                        "name": "Connection",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "enum": ["Upgrade"]
                        }
                    }
                ],
                "responses": {
                    "101": {
                        "description": "WebSocket connection established",
                        "headers": {
                            "Upgrade": {
                                "schema": {
                                    "type": "string",
                                    "enum": ["websocket"]
                                }
                            },
                            "Connection": {
                                "schema": {
                                    "type": "string",
                                    "enum": ["Upgrade"]
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/openai/chat/completions": {
            "post": {
                "summary": "OpenAI Compatible Chat Completions",
                "description": "OpenAI-compatible chat completions endpoint that converts requests to Bifrost format and returns OpenAI-compatible responses.",
                "operationId": "openaiChatCompletions",
                "tags": ["Integration - OpenAI"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ChatCompletionRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OpenAI-compatible chat completion response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/anthropic/v1/messages": {
            "post": {
                "summary": "Anthropic Compatible Messages",
                "description": "Anthropic-compatible messages endpoint that converts requests to Bifrost format and returns Anthropic-compatible responses.",
                "operationId": "anthropicMessages",
                "tags": ["Integration - Anthropic"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ChatCompletionRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Anthropic-compatible message response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/genai/v1beta/models/{model}": {
            "post": {
                "summary": "Google Gemini Compatible Completions",
                "description": "Google Gemini-compatible completions endpoint that converts requests to Bifrost format and returns Gemini-compatible responses.",
                "operationId": "geminiCompletions",
                "tags": ["Integration - Gemini"],
                "parameters": [
                    {
                        "name": "model",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Model name"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ChatCompletionRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Gemini-compatible completion response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/chat/completions": {
            "post": {
                "summary": "LiteLLM Compatible Chat Completions",
                "description": "LiteLLM-compatible chat completions endpoint that automatically detects the provider from the model name and converts requests accordingly.",
                "operationId": "litellmChatCompletions",
                "tags": ["Integration - LiteLLM"],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ChatCompletionRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "LiteLLM-compatible chat completion response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BifrostResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "500": {
                        "$ref": "#/components/responses/InternalServerError"
                    }
                }
            }
        },
        "/metrics": {
            "get": {
                "summary": "Get Prometheus Metrics",
                "description": "Returns Prometheus-compatible metrics for monitoring request counts, latency, token usage, and error rates.",
                "operationId": "getMetrics",
                "tags": ["Monitoring"],
                "responses": {
                    "200": {
                        "description": "Prometheus metrics in text format",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "type": "string"
                                },
                                "example": "# HELP http_requests_total Total number of HTTP requests\n# TYPE http_requests_total counter\nhttp_requests_total{method=\"POST\",handler=\"/v1/chat/completions\",code=\"200\"} 42\n"
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "ChatCompletionRequest": {
                "type": "object",
                "required": ["model", "messages"],
                "properties": {
                    "model": {
                        "type": "string",
                        "description": "Model identifier in 'provider/model' format (e.g., 'openai/gpt-4o-mini', 'anthropic/claude-3-sonnet-20240229')",
                        "example": "openai/gpt-4o-mini"
                    },
                    "messages": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/BifrostMessage"
                        },
                        "description": "Array of chat messages",
                        "minItems": 1
                    },
                    "params": {
                        "$ref": "#/components/schemas/ModelParameters"
                    },
                    "fallbacks": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Fallback model names in 'provider/model' format",
                        "example": ["anthropic/claude-3-sonnet-20240229", "openai/gpt-4o"]
                    }
                }
            },
            "TextCompletionRequest": {
                "type": "object",
                "required": ["model", "text"],
                "properties": {
                    "model": {
                        "type": "string",
                        "description": "Model identifier in 'provider/model' format (e.g., 'anthropic/claude-2.1')",
                        "example": "anthropic/claude-2.1"
                    },
                    "text": {
                        "type": "string",
                        "description": "Text prompt for completion",
                        "example": "The benefits of artificial intelligence include"
                    },
                    "params": {
                        "$ref": "#/components/schemas/ModelParameters"
                    },
                    "fallbacks": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Fallback model names in 'provider/model' format",
                        "example": ["anthropic/claude-3-haiku-20240307", "openai/gpt-4o-mini"]
                    }
                }
            },
            "ModelProvider": {
                "type": "string",
                "enum": [
                    "openai",
                    "anthropic",
                    "azure",
                    "bedrock",
                    "cohere",
                    "vertex",
                    "mistral",
                    "ollama",
                    "groq",
                    "sgl"
                ],
                "description": "AI model provider",
                "example": "openai"
            },
            "BifrostMessage": {
                "type": "object",
                "required": ["role"],
                "properties": {
                    "role": {
                        "$ref": "#/components/schemas/MessageRole"
                    },
                    "content": {
                        "oneOf": [
                            {
                                "type": "string",
                                "description": "Simple text content",
                                "example": "Hello, how are you?"
                            },
                            {
                                "type": "array",
                                "items": {
                                    "$ref": "#/components/schemas/ContentBlock"
                                },
                                "description": "Structured content with text and images"
                            }
                        ],
                        "description": "Message content - can be simple text or structured content with text and images"
                    },
                    "tool_call_id": {
                        "type": "string",
                        "description": "ID of the tool call (for tool messages)"
                    },
                    "tool_calls": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ToolCall"
                        },
                        "description": "Tool calls made by assistant"
                    },
                    "refusal": {
                        "type": "string",
                        "description": "Refusal message from assistant"
                    },
                    "annotations": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Annotation"
                        },
                        "description": "Message annotations"
                    },
                    "thought": {
                        "type": "string",
                        "description": "Assistant's internal thought process"
                    }
                }
            },
            "MessageRole": {
                "type": "string",
                "enum": ["user", "assistant", "system", "tool"],
                "description": "Role of the message sender",
                "example": "user"
            },
            "ContentBlock": {
                "type": "object",
                "required": ["type"],
                "discriminator": {
                    "propertyName": "type"
                },
                "oneOf": [
                    {
                        "type": "object",
                        "required": ["type", "text"],
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["text"],
                                "description": "Content type for text blocks",
                                "example": "text"
                            },
                            "text": {
                                "type": "string",
                                "description": "Text content",
                                "example": "What do you see in this image?"
                            }
                        },
                        "additionalProperties": false
                    },
                    {
                        "type": "object",
                        "required": ["type", "image_url"],
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["image_url"],
                                "description": "Content type for image blocks",
                                "example": "image_url"
                            },
                            "image_url": {
                                "$ref": "#/components/schemas/ImageURLStruct",
                                "description": "Image data"
                            }
                        },
                        "additionalProperties": false
                    }
                ]
            },
            "ImageURLStruct": {
                "type": "object",
                "required": ["url"],
                "properties": {
                    "url": {
                        "type": "string",
                        "description": "Image URL or data URI",
                        "example": "https://example.com/image.jpg"
                    },
                    "detail": {
                        "type": "string",
                        "enum": ["low", "high", "auto"],
                        "description": "Image detail level",
                        "example": "auto"
                    }
                }
            },
            "ModelParameters": {
                "type": "object",
                "properties": {
                    "temperature": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 2,
                        "description": "Controls randomness in the output",
                        "example": 0.7
                    },
                    "top_p": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1,
                        "description": "Nucleus sampling parameter",
                        "example": 0.9
                    },
                    "top_k": {
                        "type": "integer",
                        "minimum": 1,
                        "description": "Top-k sampling parameter",
                        "example": 40
                    },
                    "max_tokens": {
                        "type": "integer",
                        "minimum": 1,
                        "description": "Maximum number of tokens to generate",
                        "example": 1000
                    },
                    "stop_sequences": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Sequences that stop generation",
                        "example": ["\n\n", "END"]
                    },
                    "presence_penalty": {
                        "type": "number",
                        "minimum": -2,
                        "maximum": 2,
                        "description": "Penalizes repeated tokens",
                        "example": 0
                    },
                    "frequency_penalty": {
                        "type": "number",
                        "minimum": -2,
                        "maximum": 2,
                        "description": "Penalizes frequent tokens",
                        "example": 0
                    },
                    "tools": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Tool"
                        },
                        "description": "Available tools for the model"
                    },
                    "tool_choice": {
                        "$ref": "#/components/schemas/ToolChoice"
                    },
                    "parallel_tool_calls": {
                        "type": "boolean",
                        "description": "Enable parallel tool execution",
                        "example": true
                    }
                }
            },
            "Tool": {
                "type": "object",
                "required": ["type", "function"],
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Unique tool identifier"
                    },
                    "type": {
                        "type": "string",
                        "enum": ["function"],
                        "description": "Tool type",
                        "example": "function"
                    },
                    "function": {
                        "$ref": "#/components/schemas/Function"
                    }
                }
            },
            "Function": {
                "type": "object",
                "required": ["name", "description", "parameters"],
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "Function name",
                        "example": "get_weather"
                    },
                    "description": {
                        "type": "string",
                        "description": "Function description",
                        "example": "Get current weather for a location"
                    },
                    "parameters": {
                        "$ref": "#/components/schemas/FunctionParameters"
                    }
                }
            },
            "FunctionParameters": {
                "type": "object",
                "required": ["type"],
                "properties": {
                    "type": {
                        "type": "string",
                        "description": "Parameter type",
                        "example": "object"
                    },
                    "description": {
                        "type": "string",
                        "description": "Parameter description"
                    },
                    "properties": {
                        "type": "object",
                        "additionalProperties": true,
                        "description": "Parameter properties (JSON Schema)"
                    },
                    "required": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Required parameter names"
                    },
                    "enum": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Enum values for parameters"
                    }
                }
            },
            "ToolChoice": {
                "type": "object",
                "required": ["type"],
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": ["none", "auto", "any", "function", "required"],
                        "description": "How tools should be chosen",
                        "example": "auto"
                    },
                    "function": {
                        "$ref": "#/components/schemas/ToolChoiceFunction"
                    }
                }
            },
            "ToolChoiceFunction": {
                "type": "object",
                "required": ["name"],
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "Name of the function to call",
                        "example": "get_weather"
                    }
                }
            },
            "ToolCall": {
                "type": "object",
                "required": ["function"],
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Unique tool call identifier",
                        "example": "tool_123"
                    },
                    "type": {
                        "type": "string",
                        "enum": ["function"],
                        "description": "Tool call type",
                        "example": "function"
                    },
                    "function": {
                        "$ref": "#/components/schemas/FunctionCall"
                    }
                }
            },
            "FunctionCall": {
                "type": "object",
                "required": ["name", "arguments"],
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "Function name",
                        "example": "get_weather"
                    },
                    "arguments": {
                        "type": "string",
                        "description": "JSON string of function arguments",
                        "example": "{\"location\": \"San Francisco, CA\"}"
                    }
                }
            },
            "Annotation": {
                "type": "object",
                "required": ["type", "url_citation"],
                "properties": {
                    "type": {
                        "type": "string",
                        "description": "Annotation type"
                    },
                    "url_citation": {
                        "$ref": "#/components/schemas/Citation"
                    }
                }
            },
            "Citation": {
                "type": "object",
                "required": ["start_index", "end_index", "title"],
                "properties": {
                    "start_index": {
                        "type": "integer",
                        "description": "Start index in the text"
                    },
                    "end_index": {
                        "type": "integer",
                        "description": "End index in the text"
                    },
                    "title": {
                        "type": "string",
                        "description": "Citation title"
                    },
                    "url": {
                        "type": "string",
                        "description": "Citation URL"
                    },
                    "sources": {
                        "description": "Citation sources"
                    },
                    "type": {
                        "type": "string",
                        "description": "Citation type"
                    }
                }
            },
            "BifrostResponse": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Unique response identifier",
                        "example": "chatcmpl-123"
                    },
                    "object": {
                        "type": "string",
                        "enum": ["chat.completion", "text.completion"],
                        "description": "Response type",
                        "example": "chat.completion"
                    },
                    "choices": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/BifrostResponseChoice"
                        },
                        "description": "Array of completion choices"
                    },
                    "model": {
                        "type": "string",
                        "description": "Model used for generation",
                        "example": "gpt-4o"
                    },
                    "created": {
                        "type": "integer",
                        "description": "Unix timestamp of creation",
                        "example": 1677652288
                    },
                    "service_tier": {
                        "type": "string",
                        "description": "Service tier used"
                    },
                    "system_fingerprint": {
                        "type": "string",
                        "description": "System fingerprint"
                    },
                    "usage": {
                        "$ref": "#/components/schemas/LLMUsage"
                    },
                    "extra_fields": {
                        "$ref": "#/components/schemas/BifrostResponseExtraFields"
                    }
                }
            },
            "BifrostResponseChoice": {
                "type": "object",
                "required": ["index", "message"],
                "properties": {
                    "index": {
                        "type": "integer",
                        "description": "Choice index",
                        "example": 0
                    },
                    "message": {
                        "$ref": "#/components/schemas/BifrostMessage"
                    },
                    "finish_reason": {
                        "type": "string",
                        "enum": ["stop", "length", "tool_calls", "content_filter", "function_call"],
                        "description": "Reason completion stopped",
                        "example": "stop"
                    },
                    "stop": {
                        "type": "string",
                        "description": "Stop sequence that ended generation"
                    },
                    "log_probs": {
                        "$ref": "#/components/schemas/LogProbs"
                    }
                }
            },
            "LLMUsage": {
                "type": "object",
                "properties": {
                    "prompt_tokens": {
                        "type": "integer",
                        "description": "Tokens in the prompt",
                        "example": 56
                    },
                    "completion_tokens": {
                        "type": "integer",
                        "description": "Tokens in the completion",
                        "example": 31
                    },
                    "total_tokens": {
                        "type": "integer",
                        "description": "Total tokens used",
                        "example": 87
                    },
                    "completion_tokens_details": {
                        "$ref": "#/components/schemas/CompletionTokensDetails"
                    }
                }
            },
            "CompletionTokensDetails": {
                "type": "object",
                "properties": {
                    "reasoning_tokens": {
                        "type": "integer",
                        "description": "Tokens used for reasoning"
                    },
                    "audio_tokens": {
                        "type": "integer",
                        "description": "Tokens used for audio"
                    },
                    "accepted_prediction_tokens": {
                        "type": "integer",
                        "description": "Accepted prediction tokens"
                    },
                    "rejected_prediction_tokens": {
                        "type": "integer",
                        "description": "Rejected prediction tokens"
                    }
                }
            },
            "BifrostResponseExtraFields": {
                "type": "object",
                "properties": {
                    "provider": {
                        "$ref": "#/components/schemas/ModelProvider"
                    },
                    "model_params": {
                        "$ref": "#/components/schemas/ModelParameters"
                    },
                    "latency": {
                        "type": "number",
                        "description": "Request latency in seconds",
                        "example": 1.234
                    },
                    "chat_history": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/BifrostMessage"
                        },
                        "description": "Full conversation history"
                    },
                    "billed_usage": {
                        "$ref": "#/components/schemas/BilledLLMUsage"
                    },
                    "raw_response": {
                        "type": "object",
                        "description": "Raw provider response"
                    }
                }
            },
            "BilledLLMUsage": {
                "type": "object",
                "properties": {
                    "prompt_tokens": {
                        "type": "number",
                        "description": "Billed prompt tokens"
                    },
                    "completion_tokens": {
                        "type": "number",
                        "description": "Billed completion tokens"
                    },
                    "search_units": {
                        "type": "number",
                        "description": "Billed search units"
                    },
                    "classifications": {
                        "type": "number",
                        "description": "Billed classifications"
                    }
                }
            },
            "LogProbs": {
                "type": "object",
                "properties": {
                    "content": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ContentLogProb"
                        },
                        "description": "Log probabilities for content"
                    },
                    "refusal": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/LogProb"
                        },
                        "description": "Log probabilities for refusal"
                    }
                }
            },
            "ContentLogProb": {
                "type": "object",
                "required": ["logprob", "token"],
                "properties": {
                    "bytes": {
                        "type": "array",
                        "items": {
                            "type": "integer"
                        },
                        "description": "Byte representation"
                    },
                    "logprob": {
                        "type": "number",
                        "description": "Log probability",
                        "example": -0.123
                    },
                    "token": {
                        "type": "string",
                        "description": "Token",
                        "example": "hello"
                    },
                    "top_logprobs": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/LogProb"
                        },
                        "description": "Top log probabilities"
                    }
                }
            },
            "LogProb": {
                "type": "object",
                "required": ["logprob", "token"],
                "properties": {
                    "bytes": {
                        "type": "array",
                        "items": {
                            "type": "integer"
                        },
                        "description": "Byte representation"
                    },
                    "logprob": {
                        "type": "number",
                        "description": "Log probability",
                        "example": -0.456
                    },
                    "token": {
                        "type": "string",
                        "description": "Token",
                        "example": "world"
                    }
                }
            },
            "BifrostError": {
                "type": "object",
                "required": ["is_bifrost_error", "error"],
                "properties": {
                    "event_id": {
                        "type": "string",
                        "description": "Unique error event ID",
                        "example": "evt_123"
                    },
                    "type": {
                        "type": "string",
                        "description": "Error type",
                        "example": "invalid_request_error"
                    },
                    "is_bifrost_error": {
                        "type": "boolean",
                        "description": "Whether error originated from Bifrost",
                        "example": true
                    },
                    "status_code": {
                        "type": "integer",
                        "description": "HTTP status code",
                        "example": 400
                    },
                    "error": {
                        "$ref": "#/components/schemas/ErrorField"
                    }
                }
            },
            "ErrorField": {
                "type": "object",
                "required": ["message"],
                "properties": {
                    "type": {
                        "type": "string",
                        "description": "Error type",
                        "example": "invalid_request_error"
                    },
                    "code": {
                        "type": "string",
                        "description": "Error code",
                        "example": "missing_required_parameter"
                    },
                    "message": {
                        "type": "string",
                        "description": "Human-readable error message",
                        "example": "Provider is required"
                    },
                    "param": {
                        "description": "Parameter that caused the error",
                        "example": "provider"
                    },
                    "event_id": {
                        "type": "string",
                        "description": "Error event ID",
                        "example": "evt_123"
                    }
                }
            },
            "MCPClient": {
                "type": "object",
                "required": ["name", "config", "tools", "state"],
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "Unique name for this MCP client",
                        "example": "filesystem"
                    },
                    "config": {
                        "$ref": "#/components/schemas/MCPClientConfig"
                    },
                    "tools": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Available tools from this client",
                        "example": ["read_file", "list_directory", "write_file"]
                    },
                    "state": {
                        "$ref": "#/components/schemas/MCPConnectionState"
                    }
                }
            },
            "MCPClientConfig": {
                "type": "object",
                "required": ["name", "connection_type"],
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "Client name",
                        "example": "filesystem"
                    },
                    "connection_type": {
                        "$ref": "#/components/schemas/MCPConnectionType"
                    },
                    "connection_string": {
                        "type": "string",
                        "description": "HTTP or SSE URL (required for HTTP or SSE connections)",
                        "example": "https://api.example.com/mcp"
                    },
                    "stdio_config": {
                        "$ref": "#/components/schemas/MCPStdioConfig"
                    },
                    "tools_to_skip": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Tools to exclude from this client",
                        "example": ["delete_file", "write_file"]
                    },
                    "tools_to_execute": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Tools to include from this client (if specified, only these are used)",
                        "example": ["read_file", "list_directory"]
                    }
                }
            },
            "MCPConnectionType": {
                "type": "string",
                "enum": ["http", "stdio", "sse"],
                "description": "Communication protocol for MCP connections",
                "example": "stdio"
            },
            "MCPStdioConfig": {
                "type": "object",
                "required": ["command", "args"],
                "properties": {
                    "command": {
                        "type": "string",
                        "description": "Executable command to run",
                        "example": "npx"
                    },
                    "args": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Command line arguments",
                        "example": ["-y", "@modelcontextprotocol/server-filesystem"]
                    },
                    "envs": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Environment variables required",
                        "example": ["HOME", "USER"]
                    }
                }
            },
            "MCPConnectionState": {
                "type": "string",
                "enum": ["connected", "disconnected", "error"],
                "description": "Connection state of MCP client",
                "example": "connected"
            },
            "MCPClientToolsEdit": {
                "type": "object",
                "properties": {
                    "tools_to_execute": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Tools to allow from this client (whitelist)",
                        "example": ["read_file", "list_directory"]
                    },
                    "tools_to_skip": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Tools to block from this client (blacklist)",
                        "example": ["delete_file", "write_file"]
                    }
                }
            },
            "SuccessResponse": {
                "type": "object",
                "required": ["status", "message"],
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": ["success"],
                        "description": "Operation status",
                        "example": "success"
                    },
                    "message": {
                        "type": "string",
                        "description": "Success message",
                        "example": "Operation completed successfully"
                    }
                }
            },
            "AddProviderRequest": {
                "type": "object",
                "required": ["provider", "keys"],
                "properties": {
                    "provider": {
                        "$ref": "#/components/schemas/ModelProvider"
                    },
                    "keys": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Key"
                        },
                        "description": "API keys for the provider"
                    },
                    "network_config": {
                        "$ref": "#/components/schemas/NetworkConfig"
                    },
                    "meta_config": {
                        "type": "object",
                        "additionalProperties": true,
                        "description": "Provider-specific metadata"
                    },
                    "concurrency_and_buffer_size": {
                        "$ref": "#/components/schemas/ConcurrencyAndBufferSize"
                    },
                    "proxy_config": {
                        "$ref": "#/components/schemas/ProxyConfig"
                    }
                }
            },
            "UpdateProviderRequest": {
                "type": "object",
                "required": ["keys", "network_config", "concurrency_and_buffer_size"],
                "properties": {
                    "keys": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Key"
                        },
                        "description": "API keys for the provider"
                    },
                    "network_config": {
                        "$ref": "#/components/schemas/NetworkConfig"
                    },
                    "meta_config": {
                        "type": "object",
                        "additionalProperties": true,
                        "description": "Provider-specific metadata"
                    },
                    "concurrency_and_buffer_size": {
                        "$ref": "#/components/schemas/ConcurrencyAndBufferSize"
                    },
                    "proxy_config": {
                        "$ref": "#/components/schemas/ProxyConfig"
                    }
                }
            },
            "ProviderResponse": {
                "type": "object",
                "required": ["name", "keys", "network_config", "concurrency_and_buffer_size"],
                "properties": {
                    "name": {
                        "$ref": "#/components/schemas/ModelProvider"
                    },
                    "keys": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Key"
                        },
                        "description": "API keys for the provider"
                    },
                    "network_config": {
                        "$ref": "#/components/schemas/NetworkConfig"
                    },
                    "meta_config": {
                        "type": "object",
                        "additionalProperties": true,
                        "description": "Provider-specific metadata"
                    },
                    "concurrency_and_buffer_size": {
                        "$ref": "#/components/schemas/ConcurrencyAndBufferSize"
                    },
                    "proxy_config": {
                        "$ref": "#/components/schemas/ProxyConfig"
                    }
                }
            },
            "ListProvidersResponse": {
                "type": "object",
                "required": ["providers", "total"],
                "properties": {
                    "providers": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ProviderResponse"
                        },
                        "description": "List of configured providers"
                    },
                    "total": {
                        "type": "integer",
                        "description": "Total number of providers",
                        "example": 3
                    }
                }
            },
            "Key": {
                "type": "object",
                "required": ["value"],
                "properties": {
                    "value": {
                        "type": "string",
                        "description": "API key value or environment variable reference",
                        "example": "env.OPENAI_API_KEY"
                    },
                    "weight": {
                        "type": "number",
                        "description": "Weight for load balancing",
                        "example": 1
                    },
                    "models": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Models this key can access",
                        "example": ["gpt-4o", "gpt-4o-mini"]
                    }
                }
            },
            "NetworkConfig": {
                "type": "object",
                "properties": {
                    "timeout": {
                        "type": "integer",
                        "description": "Request timeout in seconds",
                        "example": 30
                    },
                    "max_retries": {
                        "type": "integer",
                        "description": "Maximum number of retries",
                        "example": 3
                    }
                }
            },
            "ConcurrencyAndBufferSize": {
                "type": "object",
                "properties": {
                    "concurrency": {
                        "type": "integer",
                        "description": "Maximum concurrent requests",
                        "example": 10
                    },
                    "buffer_size": {
                        "type": "integer",
                        "description": "Request buffer size",
                        "example": 100
                    }
                }
            },
            "ProxyConfig": {
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string",
                        "description": "Proxy URL",
                        "example": "http://proxy.example.com:8080"
                    },
                    "username": {
                        "type": "string",
                        "description": "Proxy username"
                    },
                    "password": {
                        "type": "string",
                        "description": "Proxy password"
                    }
                }
            },
            "ClientConfig": {
                "type": "object",
                "properties": {
                    "initial_pool_size": {
                        "type": "integer",
                        "description": "Initial pool size for sync pools",
                        "example": 100
                    },
                    "drop_excess_requests": {
                        "type": "boolean",
                        "description": "Whether to drop requests when queue is full",
                        "example": false
                    },
                    "enable_logging": {
                        "type": "boolean",
                        "description": "Whether logging is enabled",
                        "example": true
                    },
                    "prometheus_labels": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Prometheus metric labels",
                        "example": ["environment", "service"]
                    }
                }
            },
            "LogSearchResponse": {
                "type": "object",
                "required": ["logs", "total", "limit", "offset"],
                "properties": {
                    "logs": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/LogEntry"
                        },
                        "description": "Array of log entries"
                    },
                    "total": {
                        "type": "integer",
                        "description": "Total number of matching logs",
                        "example": 156
                    },
                    "limit": {
                        "type": "integer",
                        "description": "Number of logs per page",
                        "example": 50
                    },
                    "offset": {
                        "type": "integer",
                        "description": "Number of logs skipped",
                        "example": 0
                    }
                }
            },
            "LogEntry": {
                "type": "object",
                "required": ["id", "timestamp", "level", "message"],
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Unique log entry ID",
                        "example": "log_123"
                    },
                    "timestamp": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Log entry timestamp",
                        "example": "2023-12-01T10:30:00Z"
                    },
                    "level": {
                        "type": "string",
                        "enum": ["debug", "info", "warn", "error"],
                        "description": "Log level",
                        "example": "info"
                    },
                    "message": {
                        "type": "string",
                        "description": "Log message",
                        "example": "Request completed successfully"
                    },
                    "provider": {
                        "$ref": "#/components/schemas/ModelProvider"
                    },
                    "model": {
                        "type": "string",
                        "description": "Model name used",
                        "example": "gpt-4o"
                    },
                    "status": {
                        "type": "string",
                        "enum": ["success", "error"],
                        "description": "Request status",
                        "example": "success"
                    },
                    "latency": {
                        "type": "number",
                        "description": "Request latency in seconds",
                        "example": 1.234
                    },
                    "tokens": {
                        "type": "integer",
                        "description": "Total tokens used",
                        "example": 87
                    },
                    "object": {
                        "type": "string",
                        "enum": ["chat.completion", "text.completion"],
                        "description": "Request object type",
                        "example": "chat.completion"
                    }
                }
            },
            "DroppedRequestsResponse": {
                "type": "object",
                "required": ["total_dropped", "recent_drops"],
                "properties": {
                    "total_dropped": {
                        "type": "integer",
                        "description": "Total number of dropped requests",
                        "example": 5
                    },
                    "recent_drops": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/DroppedRequest"
                        },
                        "description": "Recent dropped requests"
                    }
                }
            },
            "DroppedRequest": {
                "type": "object",
                "required": ["timestamp", "reason"],
                "properties": {
                    "timestamp": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the request was dropped",
                        "example": "2023-12-01T10:30:00Z"
                    },
                    "reason": {
                        "type": "string",
                        "description": "Reason for dropping the request",
                        "example": "Queue overflow"
                    },
                    "provider": {
                        "$ref": "#/components/schemas/ModelProvider"
                    },
                    "model": {
                        "type": "string",
                        "description": "Model name requested",
                        "example": "gpt-4o"
                    }
                }
            }
        },
        "responses": {
            "BadRequest": {
                "description": "Bad Request - Invalid request format or missing required fields",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/BifrostError"
                        },
                        "example": {
                            "is_bifrost_error": true,
                            "status_code": 400,
                            "error": {
                                "type": "invalid_request_error",
                                "code": "missing_required_parameter",
                                "message": "Provider is required",
                                "param": "provider"
                            }
                        }
                    }
                }
            },
            "Unauthorized": {
                "description": "Unauthorized - Invalid or missing API key",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/BifrostError"
                        },
                        "example": {
                            "is_bifrost_error": true,
                            "status_code": 401,
                            "error": {
                                "type": "authentication_error",
                                "message": "Invalid API key provided"
                            }
                        }
                    }
                }
            },
            "RateLimited": {
                "description": "Too Many Requests - Rate limit exceeded",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/BifrostError"
                        },
                        "example": {
                            "is_bifrost_error": false,
                            "status_code": 429,
                            "error": {
                                "type": "rate_limit_error",
                                "message": "Rate limit exceeded. Please try again later."
                            }
                        }
                    }
                }
            },
            "InternalServerError": {
                "description": "Internal Server Error - Server or provider error",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/BifrostError"
                        },
                        "example": {
                            "is_bifrost_error": true,
                            "status_code": 500,
                            "error": {
                                "type": "api_error",
                                "message": "Internal server error occurred"
                            }
                        }
                    }
                }
            }
        }
    },
    "tags": [
        {
            "name": "Chat Completions",
            "description": "Create chat completions using conversational messages"
        },
        {
            "name": "Text Completions",
            "description": "Create text completions from prompts"
        },
        {
            "name": "MCP Tools",
            "description": "Execute MCP tools"
        },
        {
            "name": "MCP Management",
            "description": "Manage MCP client configurations and connections"
        },
        {
            "name": "Provider Management",
            "description": "Manage AI provider configurations"
        },
        {
            "name": "Configuration",
            "description": "System configuration management"
        },
        {
            "name": "Logging",
            "description": "Application logs and dropped requests"
        },
        {
            "name": "WebSocket",
            "description": "Real-time WebSocket connections"
        },
        {
            "name": "Integration - OpenAI",
            "description": "OpenAI-compatible endpoints"
        },
        {
            "name": "Integration - Anthropic",
            "description": "Anthropic-compatible endpoints"
        },
        {
            "name": "Integration - Gemini",
            "description": "Google Gemini-compatible endpoints"
        },
        {
            "name": "Integration - LiteLLM",
            "description": "LiteLLM-compatible endpoints"
        },
        {
            "name": "Monitoring",
            "description": "Monitoring and observability endpoint"
        }
    ]
}