Skip to content
Skillv1.0.0

anth-hello-world

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.

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/anth-hello-world/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-hello-world. Copyright stays with the author (MIT).

Anthropic Hello World

Overview

Three minimal examples covering the Claude Messages API core surfaces: basic text completion, vision (image analysis), and streaming responses.

Prerequisites

  • Completed anth-install-auth setup
  • Valid ANTHROPIC_API_KEY in environment
  • Python 3.8+ with anthropic package or Node.js 18+ with @anthropic-ai/sdk

Instructions

Example 1: Basic Text Message (Python)

import 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")

Example 2: Vision — Analyze an Image (TypeScript)

import 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 : '');

Example 3: Streaming Response (Python)

import 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}")

Output

  • Working code file with Claude client initialization
  • Successful API response with text content
  • Console output showing model response and usage metadata

Examples

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 Handling

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

Key API Parameters

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

Resources

Next Steps

Proceed to anth-local-dev-loop for development workflow setup.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-anth-hello-world/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-anth-hello-world.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-anth-hello-world",
  "kind": "skill",
  "name": "anth-hello-world",
  "description": "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\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding",
      "general_chat"
    ],
    "tags": [
      "skill-md",
      "saas",
      "ai",
      "anthropic",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "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\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/anth-hello-world/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/anth-hello-world/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/anth-hello-world/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit"
    ],
    "license": "MIT"
  },
  "instructions": "# Anthropic Hello World\n\n## Overview\n\nThree minimal examples covering the Claude Messages API core surfaces: basic text completion, vision (image analysis), and streaming responses.\n\n## Prerequisites\n\n- Completed `anth-install-auth` setup\n- Valid `ANTHROPIC_API_KEY` in environment\n- Python 3.8+ with `anthropic` package or Node.js 18+ with `@anthropic-ai/sdk`\n\n## Instructions\n\n### Example 1: Basic Text Message (Python)\n\n```python\nimport anthropic\n\nclient = anthropic.Anthropic()\n\nmessage = client.messages.create(\n    model=\"claude-sonnet-4-20250514\",\n    max_tokens=1024,\n    messages=[\n        {",
  "cost": {
    "context_tokens": 1100
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-anth-hello-world/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.