syntax = "v1" info ( title: "Cursor API Proxy" desc: "OpenAI-compatible API proxy for Cursor/Gemini" author: "cursor-api-proxy" version: "1.0" ) // ============ Types ============ type ( // Health HealthRequest {} HealthResponse { Status string `json:"status"` Version string `json:"version"` } // Models ModelsRequest {} ModelsResponse { Object string `json:"object"` Data []ModelData `json:"data"` } ModelData { Id string `json:"id"` Object string `json:"object"` OwnedBy string `json:"owned_by"` } // Chat Completions ChatCompletionRequest { Model string `json:"model"` Messages []Message `json:"messages"` Stream bool `json:"stream,optional"` Tools []Tool `json:"tools,optional"` Functions []Function `json:"functions,optional"` MaxTokens int `json:"max_tokens,optional"` Temperature float64 `json:"temperature,optional"` } Message { Role string `json:"role"` Content interface{} `json:"content"` } Tool { Type string `json:"type"` Function ToolFunction `json:"function"` } ToolFunction { Name string `json:"name"` Description string `json:"description"` Parameters interface{} `json:"parameters"` } Function { Name string `json:"name"` Description string `json:"description,optional"` Parameters interface{} `json:"parameters,optional"` } ChatCompletionResponse { Id string `json:"id"` Object string `json:"object"` Created int64 `json:"created"` Model string `json:"model"` Choices []Choice `json:"choices"` Usage Usage `json:"usage"` } Choice { Index int `json:"index"` Message RespMessage `json:"message,optional"` Delta Delta `json:"delta,optional"` FinishReason string `json:"finish_reason"` } RespMessage { Role string `json:"role"` Content string `json:"content,optional"` ToolCalls []ToolCall `json:"tool_calls,optional"` } Delta { Role string `json:"role,optional"` Content string `json:"content,optional"` ReasoningContent string `json:"reasoning_content,optional"` ToolCalls []ToolCall `json:"tool_calls,optional"` } ToolCall { Index int `json:"index"` Id string `json:"id"` Type string `json:"type"` Function FunctionCall `json:"function"` } FunctionCall { Name string `json:"name"` Arguments string `json:"arguments"` } Usage { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } // Anthropic Messages AnthropicRequest { Model string `json:"model"` Messages []Message `json:"messages"` MaxTokens int `json:"max_tokens"` Stream bool `json:"stream,optional"` System string `json:"system,optional"` } AnthropicResponse { Id string `json:"id"` Type string `json:"type"` Role string `json:"role"` Content []ContentBlock `json:"content"` Model string `json:"model"` Usage AnthropicUsage `json:"usage"` } ContentBlock { Type string `json:"type"` Text string `json:"text,optional"` } AnthropicUsage { InputTokens int `json:"input_tokens"` OutputTokens int `json:"output_tokens"` } ) // ============ Routes ============ @server ( prefix: /v1 group: chat ) service chat-api { @handler Health get /health returns (HealthResponse) @handler Models get /v1/models returns (ModelsResponse) @handler ChatCompletions post /v1/chat/completions (ChatCompletionRequest) @handler AnthropicMessages post /v1/messages (AnthropicRequest) }