Skip to main content
Available on all Portkey plans.
The Chat Completions API is the most widely adopted format for LLM interaction. Portkey makes it work with every provider — send the same POST /v1/chat/completions request to OpenAI, Anthropic, Gemini, Bedrock, or any of the 3000+ 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 3000+ supported models.

Using the OpenAI SDK

The Portkey SDK is a superset of the OpenAI SDK, so all Chat Completions methods work identically. The OpenAI SDK also works directly with Portkey’s base URL:

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 Portkey Features

Chat Completions works with all Portkey 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

Portkey Chat Completions reference

Universal API

All three API formats

Function Calling Guide

Detailed function calling guide
Last modified on February 12, 2026