Claude 3.5 Sonnet
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.
API Format: Anthropic Claude
This model uses Anthropic Claude request/response format.
1import requests
2
3url = "https://api.segmind.com/v1/claude-3.5-sonnet"
4
5headers = {
6 "Authorization": "Bearer YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "instruction": "You are a helpful assistant.",
12 "messages": [
13 {
14 "role": "user",
15 "content": [
16 {
17 "type": "text",
18 "text": "What's in this image?"
19 },
20 {
21 "type": "image",
22 "source": {
23 "type": "base64",
24 "media_type": "image/jpeg",
25 "data": "iVBORw0KGgoAAAANSUhEUgA..."
26 }
27 }
28 ]
29 }
30 ]
31}
32
33response = requests.post(url, json=data, headers=headers)
34print(response.json()) 1import requests
2
3url = "https://api.segmind.com/v1/claude-3.5-sonnet"
4
5headers = {
6 "Authorization": "Bearer YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "instruction": "You are a helpful assistant.",
12 "messages": [
13 {
14 "role": "user",
15 "content": [
16 {
17 "type": "text",
18 "text": "What's in this image?"
19 },
20 {
21 "type": "image",
22 "source": {
23 "type": "base64",
24 "media_type": "image/jpeg",
25 "data": "iVBORw0KGgoAAAANSUhEUgA..."
26 }
27 }
28 ]
29 }
30 ]
31}
32
33response = requests.post(url, json=data, headers=headers)
34print(response.json())API Endpoint
POST https://api.segmind.com/v1/claude-3.5-sonnetParameters
messagesrequiredobject[]Array of message objects with role and content array. Images must be base64 encoded with media_type.
rolerequiredstringRole of the message sender
"user""assistant"contentrequiredarrayArray of content blocks (text or image)
instructionoptionalstringSystem 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.
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid message format or parameters
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out