Claude 4.5 Sonnet
Claude Sonnet 4.5 empowers developers with advanced coding and reasoning for complex software solutions.
API
If you're looking for an API, you can choose from your desired programming language.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const axios = require('axios');
const fs = require('fs');
const path = require('path');
// helper function to help you convert your local images into base64 format
async function toB64(imgPath) {
const data = fs.readFileSync(path.resolve(imgPath));
return Buffer.from(data).toString('base64');
}
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/claude-4.5-sonnet";
const data = {
"instruction": "Respond in a playful and humorous manner, keeping the tone light and entertaining.",
"temperature": 0.1,
"messages": [
{
"role": "user",
"content": "tell me a joke on cats"
},
{
"role": "assistant",
"content": "here is a joke about cats..."
},
{
"role": "user",
"content": "now a joke on dogs"
}
]
};
(async function() {
try {
const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
})();
Attributes
System prompt to give the LLM some context
Randomness variable between 0 - 1.
An array of objects containing the role and content
Could be "user", "assistant" or "system".
A string containing the user's query or the assistant's response.
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Resources to get you started
Everything you need to know to get the most out of Claude 4.5 Sonnet
# Claude Sonnet 4.5: Effective Usage Guide
Claude Sonnet 4.5 is Anthropicâs advanced AI model for coding, reasoning and multimodal analysis. This guide shows how to tune parameters and craft prompts for different workflows, ensuring you get the best possible output.
## 1. Core Parameters
- **prompt** (string, required): Your main instruction or question. Be explicit about goals, constraints and expected format.
- **image** (image, optional): Supply diagrams, screenshots or photos when visual analysis is needed. Leave blank for textâonly tasks.
- **temperature** (0.0â1.0): Controls creativity and randomness. Low values (0.0â0.3) yield deterministic, focused results; higher (0.7â1.0) boost diversity.
- **top_p** (0.0â1.0): Nucleus sampling that limits token choices to a cumulative probability. Use 0.8â1.0 for general tasks; lower (0.5â0.7) when you want more conservative outputs.
- **max_tokens** (integer): Caps response length. Match it to your task size (e.g. 300â500 tokens for code snippets or detailed explanations).
## 2. Use Case Recommendations
1. **Code Generation & Review**
- temperature: 0.1
- top_p: 1.0
- max_tokens: 400â600
- Prompt tip: Include language, framework, input/output examples and edge cases.
2. **Complex Debugging & Optimization**
- temperature: 0.2
- top_p: 0.8
- max_tokens: 500
- Prompt tip: Paste minimal reproducible code and describe observed vs. expected behavior.
3. **Architectural Planning & Design**
- temperature: 0.3
- top_p: 0.9
- max_tokens: 600
- Prompt tip: Provide system requirements, performance targets, and scale considerations.
4. **Mathematical Modeling & Analysis**
- temperature: 0.0
- top_p: 1.0
- max_tokens: 400
- Prompt tip: Define variables, constraints and desired proof or derivation steps.
5. **Creative Writing & Documentation**
- temperature: 0.8
- top_p: 1.0
- max_tokens: 300
- Prompt tip: Specify tone, style guide, word count and key points to cover.
## 3. Prompting Best Practices
- Break complex tasks into numbered steps.
- Supply background context, example inputs/outputs and failure modes.
- Use the extended attention span for multiâstage workflowsâchain prompts and reference prior answers.
- Leverage the âimageâ parameter for diagrams, UI screenshots or chartsâannotate regions of interest.
## 4. Progress Checkpoints & Security
- For longârunning tasks, insert â## Checkpointâ markers in your prompt. After each checkpoint, review and adjust instructions.
- Claude Sonnet 4.5 is hardened against prompt injection; nonetheless, validate external inputs and enforce strict schemas in production.
By tuning these parameters and structuring prompts clearly, youâll unlock Claude Sonnet 4.5âs full potentialâwhether youâre writing production code, performing deep technical analysis or creating rich, visual documentation.
Other Popular Models
Discover other models you might be interested in.
sdxl-controlnet
SDXL ControlNet gives unprecedented control over text-to-image generation. SDXL ControlNet models Introduces the concept of conditioning inputs, which provide additional information to guide the image generation process

fooocus
Fooocus enables high-quality image generation effortlessly, combining the best of Stable Diffusion and Midjourney.

sdxl1.0-txt2img
The SDXL model is the official upgrade to the v1.5 model. The model is released as open-source software

codeformer
CodeFormer is a robust face restoration algorithm for old photos or AI-generated faces.
