Chat Completions
Create chat completions using various AI models.
Endpoint
POST https://api.fizzlyapi.com/v1/chat/completionsRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID to use (e.g., gpt-4o, claude-3-5-sonnet-20241022) |
messages | array | Yes | Array of message objects |
max_tokens | integer | No | Maximum tokens to generate |
temperature | number | No | Sampling temperature (0-2) |
top_p | number | No | Nucleus sampling parameter |
stream | boolean | No | Enable streaming responses |
stop | string/array | No | Stop sequences |
Message Object
| Field | Type | Description |
|---|---|---|
role | string | system, user, or assistant |
content | string | Message content |
Examples
curl https://api.fizzlyapi.com/v1/chat/completions \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"max_tokens": 100
}'Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1703123456,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}Available Models
Fizzly API supports 200+ AI models. For the complete list and pricing, see Model Gallery.
Common models:
openai/gpt-4o- GPT-4o multimodalopenai/o3-mini- Efficient reasoninganthropic/claude-sonnet-4- Claude latest flagshipgoogle/gemini-2.5-pro- Gemini latest flagshipdeepseek/deepseek-chat- DeepSeek V3
Model name format: provider/model-name, e.g., openai/gpt-4o, anthropic/claude-sonnet-4.
Multi-turn Conversation
For multi-turn conversations, include the conversation history:
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is 2+2?"},
{"role": "assistant", "content": "2+2 equals 4."},
{"role": "user", "content": "And what is 4+4?"}
]
response = client.chat.completions.create(
model="gpt-4o",
messages=messages
)Tips
- Use system messages to set the AI’s behavior and context
- Keep conversation history for context-aware responses
- Set appropriate max_tokens to control response length and cost
- Use streaming for real-time responses in chat applications