Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Create a minimal working Anthropic Claude Messages API example. Use when starting a new Claude integration, testing your setup, or learning basic Messages API patterns for text, vision, and streaming. Trigger with phrases like "anthropic hello world", "claude api example", "anthropic quick start", "simple claude code", "first messages api call".
.claude/skills/jeremylongshore-anth-hello-world/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 101% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 0% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 26% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 73% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 28% | 0% |
Three minimal examples covering the Claude Messages API core surfaces: basic text completion, vision (image analysis), and streaming responses.
anth-install-auth setupANTHROPIC_API_KEY in environmentanthropic package or Node.js 18+ with @anthropic-ai/sdkpythonimport anthropic client = anthropic.Anthropic() message = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[ {"role": "user", "content": "Explain quantum computing in 3 sentences."} ] ) # Response structure print(message.content[0].text) # The actual text response print(f"ID: {message.id}") # msg_01XFDUDYJgAACzvnptvVoYEL print(f"Model: {message.model}") # claude-sonnet-4-20250514 print(f"Stop: {message.stop_reason}")# end_turn print(f"Usage: {message.usage.input_tokens}in / {message.usage.output_tokens}out")
typescriptimport Anthropic from '@anthropic-ai/sdk'; import * as fs from 'fs'; const client = new Anthropic(); // From file (base64) const imageData = fs.readFileSync('chart.png').toString('base64'); const message = await client.messages.create({ model: 'claude-sonnet-4-20250514', max_tokens: 1024, messages: [{ role: 'user', content: [ { type: 'image', source: { type: 'base64', media_type: 'image/png', data: imageData, }, }, { type: 'text', text: 'Describe what this chart shows.' }, ], }], }); console.log(message.content[0].type === 'text' ? message.content[0].text : '');
pythonimport anthropic client = anthropic.Anthropic() with client.messages.stream( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{"role": "user", "content": "Write a haiku about APIs."}] ) as stream: for text in stream.text_stream: print(text, end="", flush=True) # Get final message with full metadata final = stream.get_final_message() print(f"\nTokens used: {final.usage.input_tokens}+{final.usage.output_tokens}")
Use the text example first when verifying credentials: send a fixed, short prompt and confirm that message.content[0].text is present before integrating the client into application code. Use the vision example only after that check passes and replace chart.png with a non-sensitive local fixture. For an interactive command-line feature, use the streaming example so text is emitted incrementally, then read the final message to capture token usage for logs or cost controls.
| Error | HTTP Code | Cause | Solution | |-------|-----------|-------|----------| | authentication_error | 401 | Invalid API key | Check ANTHROPIC_API_KEY | | invalid_request_error | 400 | Bad params (e.g., empty messages) | Validate request body | | rate_limit_error | 429 | Too many requests | Implement backoff (see anth-rate-limits) | | overloaded_error | 529 | API temporarily overloaded | Retry after 30-60s | | api_error | 500 | Server error | Retry with exponential backoff |
| Parameter | Required | Description | |-----------|----------|-------------| | model | Yes | Model ID: claude-sonnet-4-20250514, claude-haiku-4-20250514, claude-opus-4-20250514 | | max_tokens | Yes | Maximum output tokens (model-dependent max) | | messages | Yes | Array of {role, content} objects | | system | No | System prompt (string or content blocks) | | temperature | No | 0.0-1.0, default 1.0 | | top_p | No | Nucleus sampling (use temperature OR top_p) | | stop_sequences | No | Array of strings that stop generation | | stream | No | Enable SSE streaming |
Proceed to anth-local-dev-loop for development workflow setup.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 5,576 | 7,004 | +26% | 1 | 1 | 0% | 1,318 | 2,958 | +124% | 0 | 0 | — |
case-02 | fail→fail | 5,620 | 4,836 | -14% | 1 | 1 | 0% | 1,154 | 2,100 | +82% | 0 | 0 | — |
case-03 | fail→pass | 5,957 | 5,925 | -1% | 1 | 1 | 0% | 1,230 | 2,475 | +101% | 0 | 0 | — |
case-04 | pass→pass | 5,321 | 3,173 | -40% | 1 | 1 | 0% | 1,112 | 1,915 | +72% | 0 | 0 | — |
case-05 | fail→pass | 8,553 | 2,338 | -73% | 1 | 1 | 0% | 1,630 | 1,630 | 0% | 0 | 0 | — |
case-06 | pass→fail | 2,713 | 2,093 | -23% | 1 | 1 | 0% | 509 | 1,595 | +213% | 0 | 0 | — |
case-07 | fail→fail | 4,898 | 1,760 | -64% | 1 | 1 | 0% | 852 | 1,571 | +84% | 0 | 0 | — |
case-08 | fail→pass | 6,505 | 2,402 | -63% | 1 | 1 | 0% | 1,368 | 1,728 | +26% | 0 | 0 | — |
case-09 | pass→pass | 7,605 | 3,689 | -51% | 1 | 1 | 0% | 1,423 | 1,923 | +35% | 0 | 0 | — |
case-10 | fail→pass | 4,814 | 1,697 | -65% | 1 | 1 | 0% | 896 | 1,549 | +73% | 0 | 0 | — |
case-11 | pass→pass | 12,078 | 3,247 | -73% | 1 | 1 | 0% | 2,403 | 1,908 | -21% | 0 | 0 | — |
case-12 | fail→fail | 7,095 | 3,999 | -44% | 1 | 1 | 0% | 1,540 | 1,951 | +27% | 0 | 0 | — |
case-13 | pass→pass | 4,080 | 2,271 | -44% | 1 | 1 | 0% | 739 | 1,559 | +111% | 0 | 0 | — |
case-14 | fail→pass | 6,753 | 1,268 | -81% | 1 | 1 | 0% | 1,112 | 1,427 | +28% | 0 | 0 | — |
case-15 | fail→fail | 3,837 | 2,606 | -32% | 1 | 1 | 0% | 701 | 1,538 | +119% | 0 | 0 | — |
case-16 | pass→pass | 9,273 | 4,320 | -53% | 1 | 1 | 0% | 1,679 | 2,053 | +22% | 0 | 0 | — |
case-17 | pass→pass | 4,576 | 2,935 | -36% | 1 | 1 | 0% | 914 | 1,771 | +94% | 0 | 0 | — |
case-18 | fail→fail | 2,687 | 1,184 | -56% | 1 | 1 | 0% | 435 | 1,393 | +220% | 0 | 0 | — |
case-19 | pass→pass | 4,070 | 3,844 | -6% | 1 | 1 | 0% | 869 | 1,929 | +122% | 0 | 0 | — |
case-20 | pass→pass | 19,410 | 25,386 | +31% | 1 | 1 | 0% | 3,922 | 6,853 | +75% | 0 | 0 | — |
case-21 | pass→pass | 11,230 | 9,568 | -15% | 1 | 1 | 0% | 2,171 | 2,964 | +37% | 0 | 0 | — |
case-22 | pass→pass | 16,016 | 13,810 | -14% | 1 | 1 | 0% | 3,038 | 4,105 | +35% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +18 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
The publisher has shipped newer versions since this run, so these numbers describe v1, not the version currently listed.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.