Skip to main content
Available on all AI Gateway plans.
The Chat Completions API is the most widely adopted format for LLM interaction. The AI Gateway makes it work with every provider — send the same POST /v1/chat/completions request to OpenAI, Anthropic, Gemini, Bedrock, or any of the 3,000+ supported models.

Quick Start

Switch model to use any provider — @anthropic-provider/claude-sonnet-4-5-20250514, @google-provider/gemini-2.0-flash, or any of the 3,000+ supported models.

Using the OpenAI SDK

Point the OpenAI SDK at the AI Gateway’s base URL and all Chat Completions methods work unchanged:

System Messages

Set a system prompt using the system role in the messages array:

Streaming

Stream responses token-by-token with stream: true.

Function Calling

Define tools with the tools parameter. Works across all providers that support function calling.

Function Call Results

Pass tool results back to continue the conversation:

Vision

Send images in the content array using the image_url type. Works with all vision-capable models.
Base64-encoded images are also supported — pass a data URL as the url value:
Python

Structured Output

JSON Schema

Force the model to return structured JSON matching a specific schema:

JSON Mode

For free-form JSON output without a strict schema:

Multi-turn Conversations

Pass the full conversation history in the messages array:

Using with AI Gateway Features

Chat Completions works with all AI Gateway features:
  • Configs — Route, load balance, and set fallbacks
  • Caching — Cache responses for faster, cheaper calls
  • Guardrails — Add input/output guardrails
  • Observability — Full logging and tracing

API Reference

OpenAI Chat API Docs

OpenAI specification

API Reference

AI Gateway Chat Completions reference

Universal API

All three API formats

Function Calling Guide

Detailed function calling guide
Last modified on September 15, 2026