Skip to main content

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?"
      }
    ]
}'

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."
          }
        ]
      }
    ]
  }'

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

model
string
required
The model that will complete your prompt.
messages
array
required
Input messages.
max_tokens
integer
required
The maximum number of tokens to generate before stopping.
system
string
System prompt.
temperature
number
Amount of randomness injected into the response.
top_p
number
Use nucleus sampling.
top_k
integer
Only sample from the top K options for each subsequent token.
stop_sequences
array
Custom text sequences that will cause the model to stop generating.
stream
boolean
Whether to incrementally stream the response using server-sent events.
metadata
object
An object describing metadata about the request.
tools
array
How the model should use the provided tools.
tool_choice
object
Forces the model to use a specific tool.
thinking
object
Configuration for extended thinking.
service_tier
string
The service tier for the request.

Params to Avoid

ParamReason
containerUnsupported
context_managementUnsupported