205 lines
5.9 KiB
Plaintext
205 lines
5.9 KiB
Plaintext
{
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"description": "OpenAI-compatible and Anthropic-compatible LLM proxy/gateway with Bifrost mapping. All configuration is loaded from environment variables.",
|
|
"title": "LLM Gateway API",
|
|
"termsOfService": "http://swagger.io/terms/",
|
|
"contact": {
|
|
"name": "optoant",
|
|
"email": "admin@optoant.local"
|
|
},
|
|
"license": {
|
|
"name": "MIT",
|
|
"url": "https://opensource.org/licenses/MIT"
|
|
},
|
|
"version": "1.0"
|
|
},
|
|
"host": "localhost:8000",
|
|
"basePath": "/",
|
|
"paths": {
|
|
"/health": {
|
|
"get": {
|
|
"description": "Returns service health status, database connectivity, and active configuration.",
|
|
"produces": ["application/json"],
|
|
"tags": ["health"],
|
|
"summary": "Health check",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/HealthResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/v1/{path}": {
|
|
"post": {
|
|
"security": [{"BearerAuth": []}],
|
|
"description": "Forwards any /v1/* request to the configured OpenAI-compatible backend (e.g. DeepSeek). The Authorization header and all standard headers are passed through.",
|
|
"consumes": ["application/json"],
|
|
"produces": ["application/json"],
|
|
"tags": ["openai"],
|
|
"summary": "OpenAI-compatible proxy",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "OpenAI API path (e.g. chat/completions)",
|
|
"name": "path",
|
|
"in": "path",
|
|
"required": true
|
|
},
|
|
{
|
|
"description": "OpenAI chat completions request",
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/OpenAIChatRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Upstream response forwarded as-is"
|
|
},
|
|
"502": {
|
|
"description": "Bad Gateway — upstream unreachable",
|
|
"schema": {
|
|
"$ref": "#/definitions/ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/anthropic/{path}": {
|
|
"post": {
|
|
"security": [{"BearerAuth": []}],
|
|
"description": "Converts Anthropic Messages API requests to OpenAI format, forwards to OPENAI_BACKEND, and converts the response back to Anthropic format.",
|
|
"consumes": ["application/json"],
|
|
"produces": ["application/json"],
|
|
"tags": ["anthropic"],
|
|
"summary": "Anthropic-compatible proxy",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Anthropic API path (e.g. v1/messages)",
|
|
"name": "path",
|
|
"in": "path",
|
|
"required": true
|
|
},
|
|
{
|
|
"description": "Anthropic Messages API request",
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/AnthropicRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Response in Anthropic format",
|
|
"schema": {
|
|
"$ref": "#/definitions/AnthropicResponse"
|
|
}
|
|
},
|
|
"502": {
|
|
"description": "Bad Gateway — upstream unreachable",
|
|
"schema": {
|
|
"$ref": "#/definitions/ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"HealthResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"status": {"type": "string", "example": "ok"},
|
|
"database": {"type": "string", "example": "ok"},
|
|
"config": {
|
|
"type": "object",
|
|
"properties": {
|
|
"openai_backend": {"type": "string"},
|
|
"port": {"type": "string"}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"OpenAIChatRequest": {
|
|
"type": "object",
|
|
"required": ["model", "messages"],
|
|
"properties": {
|
|
"model": {"type": "string", "example": "gpt-4"},
|
|
"messages": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"role": {"type": "string", "example": "user"},
|
|
"content": {"type": "string", "example": "Hello!"}
|
|
}
|
|
}
|
|
},
|
|
"stream": {"type": "boolean", "example": false}
|
|
}
|
|
},
|
|
"AnthropicRequest": {
|
|
"type": "object",
|
|
"required": ["model", "max_tokens", "messages"],
|
|
"properties": {
|
|
"model": {"type": "string", "example": "claude-3-5-sonnet-20241022"},
|
|
"max_tokens": {"type": "integer", "example": 1024},
|
|
"system": {"type": "string", "example": "You are a helpful assistant."},
|
|
"messages": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"role": {"type": "string", "example": "user"},
|
|
"content": {"type": "string", "example": "Hello!"}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"AnthropicResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {"type": "string"},
|
|
"type": {"type": "string", "example": "message"},
|
|
"role": {"type": "string", "example": "assistant"},
|
|
"model": {"type": "string"},
|
|
"stop_reason": {"type": "string", "example": "end_turn"},
|
|
"content": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {"type": "string", "example": "text"},
|
|
"text": {"type": "string"}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"ErrorResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"error": {"type": "string", "example": "upstream error: connection refused"}
|
|
}
|
|
}
|
|
},
|
|
"securityDefinitions": {
|
|
"BearerAuth": {
|
|
"type": "apiKey",
|
|
"name": "Authorization",
|
|
"in": "header"
|
|
}
|
|
}
|
|
}
|