Documentation Index
Fetch the complete documentation index at: https://docs.samuraiapi.in/llms.txt
Use this file to discover all available pages before exploring further.
The model ID to use. See the Models reference for all available IDs.Popular values: gpt-4o, gpt-4o-mini, claude-3-5-sonnet-20241022, gemini-2.0-flash, deepseek-chat
Array of conversation messages. Each message has a role (system, user, assistant) and content.
Sampling temperature from 0 to 2. Lower = more deterministic, higher = more creative.
Maximum tokens to generate. If omitted, uses the model’s default.
If true, streams partial tokens via Server-Sent Events. See Streaming.
Nucleus sampling. Only sample from top p probability mass. Use temperature OR top_p, not both.
Penalizes tokens based on how often they appear in the text so far. Range: -2.0 to 2.0.
Penalizes tokens based on whether they have appeared at all so far. Range: -2.0 to 2.0.
Up to 4 stop sequences. The API will stop generating further tokens when it encounters any of these.
Number of completions to generate. Each counts toward your usage.
A unique identifier for your end-user. Helps with abuse monitoring.
curl https://www.samuraiapi.in/v1/chat/completions \
-H "Authorization: Bearer $SAMURAI_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 Japan?"}
],
"temperature": 0.7,
"max_tokens": 150
}'
{
"id": "chatcmpl-abc123xyz",
"object": "chat.completion",
"created": 1715000000,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Tokyo is the capital of Japan. It is also the most populous metropolitan area in the world."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 22,
"total_tokens": 50
}
}