Overview
The Chat Completions endpoint provides a unified OpenAI-compatible interface to interact with multiple LLM providers. Use this endpoint to send messages and receive responses from models across providers like OpenAI, Anthropic, Google, and more.Endpoint
Authentication
Include your Helicone API key in the request:Request Body
string
required
The model to use for completion. Supports comma-separated fallback models (e.g.,
"gpt-4,claude-3-5-sonnet-20241022").See supported models for the full list.array
required
An array of message objects that form the conversation history.Each message must include:
role: One of"system","user","assistant","tool", or"developer"content: The message content (string or array of content parts)
integer
The maximum number of tokens to generate in the completion.
integer
Alternative to
max_tokens. The maximum number of tokens to generate.number
Sampling temperature between 0 and 2. Higher values make output more random.Default:
1.0number
Nucleus sampling parameter. The model considers tokens with top_p probability mass.Default:
1.0integer
Number of completions to generate. Must be between 1 and 128.Default:
1boolean
Whether to stream the response as server-sent events.Default:
falseobject
Options for streaming responses.
include_usage: Whether to include usage statistics in streaminclude_obfuscation: Whether to include obfuscation data
string | array
Up to 4 sequences where the API will stop generating tokens.
number
Number between -2.0 and 2.0. Positive values penalize tokens based on their frequency.Default:
0number
Number between -2.0 and 2.0. Positive values penalize tokens based on their presence.Default:
0boolean
Whether to return log probabilities of output tokens.Default:
falseinteger
Number of most likely tokens to return at each position (0-20). Requires
logprobs: true.object
Modify likelihood of specified tokens appearing. Maps token IDs to bias values (-100 to 100).
string
A unique identifier for the end-user, for abuse monitoring.
integer
Seed for deterministic sampling. Must be between -9223372036854775808 and 9223372036854775807.
object
Format of the response. Options:
{"type": "text"}- Plain text response{"type": "json_object"}- Valid JSON object{"type": "json_schema", "json_schema": {...}}- JSON matching schema
array
List of tools the model can call. Each tool has:
type:"function"or"custom"function: Function definition withname,description, andparameters
string | object
Controls which tool is called:
"none": No tool is called"auto": Model decides"required": Model must call a tool- Object: Force specific tool
boolean
Whether to enable parallel function calling.Default:
truestring
Level of reasoning effort for models that support it. Options:
"minimal", "low", "medium", "high"object
Advanced reasoning options:
budget_tokens: Token budget for reasoning
array
Output modalities supported by the model. Currently supports
["text"].object
Predicted content to optimize latency:
type:"content"content: Predicted message contentreasoning: Optional reasoning text
object
Context management configuration (Anthropic models only):
enabled: Enable context editingclear_tool_uses: Auto-clear tool call historyclear_thinking: Manage reasoning traces
boolean
Whether to store the completion for later use.Default:
falseobject
Additional metadata to attach to the request.
string
Service tier for the request. Options:
"auto", "default", "flex", "scale", "priority"object
Cache control settings:
type:"ephemeral"ttl: Time to live for cached response
Helicone-Specific Parameters
Model Fallbacks
Provide multiple models separated by commas for automatic fallback:Provider Exclusion
Exclude specific providers using the! prefix:
Prompt Integration
Use stored prompts with variable substitution:string
ID of the Helicone prompt to use
string
Specific version of the prompt (optional)
string
Environment for prompt resolution (e.g.,
"production", "staging")object
Variables to substitute in the prompt template
Plugins
array
Array of plugins to apply to the request. Each plugin configures additional functionality.
Response Format
string
Unique identifier for the completion
string
Object type, always
"chat.completion"integer
Unix timestamp of when the completion was created
string
The model used for completion
array
Array of completion choices. Each choice contains:
index: Choice indexmessage: The generated message withroleandcontentfinish_reason: Reason completion stopped ("stop","length","tool_calls", etc.)logprobs: Log probabilities if requested
object
Token usage statistics:
prompt_tokens: Tokens in the promptcompletion_tokens: Tokens in the completiontotal_tokens: Total tokens used
string
System fingerprint for the model configuration
Examples
Basic Chat Completion
Streaming Response
Function Calling
Model Fallback
Using Stored Prompts
Response Example
Error Responses
The endpoint returns standard HTTP status codes:400: Invalid request (missing required fields, invalid model, etc.)401: Authentication failed403: Access forbidden (suspended account, etc.)429: Rate limit exceeded or insufficient credits500: Internal server error
Additional Headers
Helicone supports custom headers for enhanced functionality:Helicone-User-Id: Track requests by userHelicone-Session-Id: Group requests into sessionsHelicone-Property-*: Add custom propertiesHelicone-Cache-Enabled: Enable response cachingHelicone-RateLimit-Policy: Apply custom rate limitsHelicone-Prompt-Id: Use a stored prompt
