openapi: 3.1.0 info: title: Vercel AI Gateway API description: >- The Vercel AI Gateway provides a unified API to access hundreds of AI models from multiple providers (Anthropic, OpenAI, Google, Meta, Mistral, and more) through a single endpoint. Features include one API key for hundreds of models, spend monitoring, automatic retries and fallbacks, provider routing by cost/latency/throughput, embeddings support, and zero markup on token pricing. Compatible with the AI SDK, OpenAI SDK, and Anthropic SDK. version: 1.0.0 contact: name: Vercel Support url: https://vercel.com/help termsOfService: https://vercel.com/legal/terms servers: - url: https://ai-gateway.vercel.sh description: Vercel AI Gateway tags: - name: Models description: List available AI models - name: Chat description: Chat completions (OpenAI-compatible) - name: Embeddings description: Text embeddings paths: /v1/models: get: operationId: listModels summary: List Models description: >- Returns all available AI models accessible through the Vercel AI Gateway. Compatible with the OpenAI models API format. tags: - Models responses: '200': description: List of available models content: application/json: schema: $ref: '#/components/schemas/ModelsResponse' '401': $ref: '#/components/responses/Unauthorized' /v1/chat/completions: post: operationId: createChatCompletion summary: Create Chat Completion description: >- Create a chat completion using any model accessible via the Vercel AI Gateway. Supports streaming, tool calls, image inputs, and provider routing options. Compatible with the OpenAI Chat Completions API. tags: - Chat requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ChatCompletionRequest' responses: '200': description: Chat completion response or SSE stream content: application/json: schema: $ref: '#/components/schemas/ChatCompletionResponse' text/event-stream: schema: type: string description: Server-sent events stream of completion chunks '401': $ref: '#/components/responses/Unauthorized' '429': $ref: '#/components/responses/RateLimitExceeded' /v1/embeddings: post: operationId: createEmbedding summary: Create Embedding description: >- Create text embeddings using any embedding model accessible via the Vercel AI Gateway. Compatible with the OpenAI Embeddings API. tags: - Embeddings requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/EmbeddingRequest' responses: '200': description: Embedding response content: application/json: schema: $ref: '#/components/schemas/EmbeddingResponse' '401': $ref: '#/components/responses/Unauthorized' '429': $ref: '#/components/responses/RateLimitExceeded' components: securitySchemes: BearerAuth: type: http scheme: bearer description: Vercel AI Gateway API key (AI_GATEWAY_API_KEY) schemas: Model: type: object properties: id: type: string description: "Model identifier in format 'provider/model-name' (e.g., 'anthropic/claude-opus-4.6')" object: type: string default: model created: type: integer description: Unix timestamp owned_by: type: string description: Provider name ModelsResponse: type: object properties: object: type: string default: list data: type: array items: $ref: '#/components/schemas/Model' Message: type: object required: - role - content properties: role: type: string enum: - system - user - assistant - tool description: Message role content: oneOf: - type: string description: Text content - type: array description: Multi-modal content array items: oneOf: - type: object description: Text content part properties: type: type: string enum: [text] text: type: string - type: object description: Image content part properties: type: type: string enum: [image_url] image_url: type: object properties: url: type: string description: Image URL or base64 data URI detail: type: string enum: [auto, low, high] name: type: string description: Optional name for the message author tool_call_id: type: string description: Tool call ID (for tool messages) Tool: type: object properties: type: type: string enum: [function] function: type: object properties: name: type: string description: type: string parameters: type: object description: JSON Schema for function parameters ProviderOptions: type: object description: Gateway-specific routing options properties: gateway: type: object properties: order: type: array items: type: string description: Ordered list of providers to try (fallback chain) sort: type: string enum: - cost - ttft - tps description: Automatically sort providers by cost, time-to-first-token, or tokens-per-second ChatCompletionRequest: type: object required: - model - messages properties: model: type: string description: "Model ID in format 'provider/model-name' (e.g., 'anthropic/claude-opus-4.6', 'openai/gpt-4o')" example: anthropic/claude-opus-4.6 messages: type: array items: $ref: '#/components/schemas/Message' description: Conversation messages stream: type: boolean default: false description: Whether to stream the response using SSE temperature: type: number minimum: 0 maximum: 2 description: Sampling temperature max_tokens: type: integer description: Maximum tokens to generate tools: type: array items: $ref: '#/components/schemas/Tool' description: Available tools for the model tool_choice: oneOf: - type: string enum: [none, auto, required] - type: object description: Tool selection strategy providerOptions: $ref: '#/components/schemas/ProviderOptions' provider: type: object properties: sort: type: string enum: [cost, ttft, tps] description: Provider sorting strategy shorthand ChatCompletionResponse: type: object properties: id: type: string object: type: string default: chat.completion created: type: integer model: type: string choices: type: array items: type: object properties: index: type: integer message: $ref: '#/components/schemas/Message' finish_reason: type: string enum: - stop - length - tool_calls - content_filter usage: type: object properties: prompt_tokens: type: integer completion_tokens: type: integer total_tokens: type: integer EmbeddingRequest: type: object required: - model - input properties: model: type: string description: Embedding model identifier example: openai/text-embedding-3-small input: oneOf: - type: string - type: array items: type: string description: Text to embed encoding_format: type: string enum: - float - base64 default: float EmbeddingResponse: type: object properties: object: type: string default: list data: type: array items: type: object properties: object: type: string default: embedding index: type: integer embedding: type: array items: type: number model: type: string usage: type: object properties: prompt_tokens: type: integer total_tokens: type: integer Error: type: object properties: error: type: object properties: message: type: string type: type: string code: type: string responses: Unauthorized: description: Missing or invalid Bearer token content: application/json: schema: $ref: '#/components/schemas/Error' RateLimitExceeded: description: Rate limit or spend limit exceeded content: application/json: schema: $ref: '#/components/schemas/Error' security: - BearerAuth: []