Request
curl --request POST \
--url https://api.znapai.com/v1/messages \
--header 'x-api-key: $ZnapAI_API_KEY' \
--header "content-type: application/json" \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 200,
"messages": [
{
"role": "user",
"content": "What is 2+2?"
}
]
}'
from anthropic import Anthropic
client = Anthropic(
api_key="$ZnapAI_API_KEY",
base_url="https://api.znapai.com/"
)
message = client.messages.create(
max_tokens=200,
messages=[
{
"role": "user",
"content": "What is 2+2?"
}
],
model="claude-sonnet-4-6",
)
print(message)
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({
apiKey: '$ZnapAI_API_KEY',
baseURL: 'https://api.znapai.com/',
});
const message = await anthropic.messages.create({
max_tokens: 200,
messages: [{ role: 'user', content: 'What is 2+2?' }],
model: 'claude-sonnet-4-6',
});
console.log(message);
Response
{
"model": "claude-sonnet-4-6",
"id": "msg_bdrk_013o7o9n5vpgAoN7PwkFBcAx",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "2 + 2 = **4**"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"stop_details": null,
"usage": {
"input_tokens": 14,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
},
"output_tokens": 14,
"total_tokens": 28
}
}
Vision (Image to Text)
You can also pass images to the model for image-to-text generation.Request
curl https://api.znapai.com/v1/messages \
--header 'x-api-key: $ZnapAI_API_KEY' \
--header "content-type: application/json" \
--data '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "'"$(base64 -w 0 image.jpg)"'"
}
},
{
"type": "text",
"text": "Describe this image in detail."
}
]
}
]
}'
from anthropic import Anthropic
import base64
client = Anthropic(
api_key="$ZnapAI_API_KEY",
base_url="https://api.znapai.com/"
)
with open("path/to/image.jpg", "rb") as image_file:
image_data = base64.b64encode(image_file.read()).decode("utf-8")
message = client.messages.create(
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": image_data
}
},
{
"type": "text",
"text": "Describe this image in detail."
}
]
}
],
model="claude-sonnet-4-6",
)
print(message)
import Anthropic from "@anthropic-ai/sdk";
import fs from "fs";
const anthropic = new Anthropic({
apiKey: "$ZnapAI_API_KEY",
baseURL: "https://api.znapai.com/",
});
const image_data = fs
.readFileSync(
"path/to/image.jpg",
)
.toString("base64");
const message = await anthropic.messages.create({
max_tokens: 1024,
messages: [
{
role: "user",
content: [
{
type: "image",
source: {
type: "base64",
media_type: "image/jpeg",
data: image_data,
},
},
{
type: "text",
text: "Describe this image in detail.",
},
],
},
],
model: "claude-sonnet-4-6",
});
console.log(message);
Response
{
"model": "claude-sonnet-4-6",
"id": "msg_bdrk_01GTCduzzD8M7XfeXwx39Ltd",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "## Long Exposure Night Photography — Urban Highway\n\nThis is a **long exposure photograph** taken at night on a multi-lane urban road or highway, capturing the dynamic energy of city traffic.\n\n### Key Elements:\n\n**Light Trails**\n- Vivid **red, orange, and white streaks** streak across the road surface, created by vehicle headlights and taillights during the extended exposure\n- The trails suggest **heavy, fast-moving traffic** flowing in multiple lanes\n\n**Infrastructure**\n- A **large overhead bridge or flyover** dominates the upper right corner\n- Tall **street lamps** with warm sodium/LED lighting illuminate the scene from the left\n- **Street light poles** line the median and roadside\n\n**Vegetation**\n- **Trees illuminated in green and yellow** from artificial lighting are visible along the median/divider\n- The greenery suggests a well-maintained urban boulevard\n\n**Atmosphere**\n- The **dark night sky** contrasts dramatically with the colorful light trails\n- Blue and cyan light streaks in the distance add visual depth\n- The slight **camera movement** or zoom during exposure adds to the sense of **speed and motion**\n\n### Technical Notes:\n- Likely shot with a **slow shutter speed** (several seconds)\n- The image has a **cinematic, abstract quality** typical of intentional long-exposure urban photography"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"stop_details": null,
"usage": {
"input_tokens": 1578,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
},
"output_tokens": 301,
"total_tokens": 1879
}
}
Parameters
string
required
The model that will complete your prompt.
array
required
Input messages.
integer
required
The maximum number of tokens to generate before stopping.
string
System prompt.
number
Amount of randomness injected into the response.
number
Use nucleus sampling.
integer
Only sample from the top K options for each subsequent token.
array
Custom text sequences that will cause the model to stop generating.
boolean
Whether to incrementally stream the response using server-sent events.
object
An object describing metadata about the request.
array
How the model should use the provided tools.
object
Forces the model to use a specific tool.
object
Configuration for extended thinking.
string
The service tier for the request.
Params to Avoid
| Param | Reason |
|---|---|
container | Unsupported |
context_management | Unsupported |
