Claude 3.5 Sonnet Serverless API

Claude 3.5 Sonnet represents a significant advancement in AI language models, combining speed, accuracy, and visual reasoning capabilities. It excels at understanding and completing requests thoughtfully, and does so much faster than previous versions. Additionally, it boasts a stronger vision model, allowing it to analyze visual data like charts and images with exceptional accuracy.

~11.20s

API Format: Anthropic Claude

This model uses Anthropic Claude request/response format.

POST /v2/claude-3.5-sonnet · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5payload = {
 6    "instruction": "You are a helpful assistant.",
 7    "messages": [
 8        {
 9            "role": "user",
10            "content": [
11                {
12                    "type": "text",
13                    "text": "What's in this image?"
14                },
15                {
16                    "type": "image",
17                    "source": {
18                        "type": "base64",
19                        "media_type": "image/jpeg",
20                        "data": "iVBORw0KGgoAAAANSUhEUgA..."
21                    }
22                }
23            ]
24        }
25    ]
26}
27
28# Async chat (v2): submit to the queue, block until COMPLETED.
29reply = segmind.chat("claude-3.5-sonnet", **payload)
30print(reply.text)
31
32# --- Or get a handle (track request_id, control the poll cadence) ---
33job = segmind.submit_chat("claude-3.5-sonnet", **payload)
34print(job.request_id)                         # available immediately
35reply = job.wait(timeout=600)
36print(reply.text)

API Endpoint

POST https://api.segmind.com/v1/claude-3.5-sonnet

Parameters

messagesrequired
object[]

Array of message objects with role and content array. Images must be base64 encoded with media_type.

Array items:
rolerequired
string

Role of the message sender

Allowed values :
"user""assistant"
contentrequired
array

Array of content blocks (text or image)

instructionoptional
string

System instruction that guides the model's behavior (replaces system message).

Response Format

{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "I can see a beautiful sunset over the ocean with vibrant orange and pink hues in the sky."
    }
  ],
  "model": "claude-3.5-sonnet",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 56,
    "output_tokens": 31
  }
}

Image Input Format

Important: Anthropic Claude Format

Images must be base64 encoded in the source.data field with media_type specified

This model supports vision capabilities. You can include images in your requests.

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/claude-3.5-sonnet

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid message format or parameters

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out