The Claude SDK for Pharo provides access to the Claude API from Pharo applications. Send messages, stream responses, use tools, upload files, and access the full Claude API surface — all from a live Pharo 12 image.
Load via Metacello:
Metacello new
baseline: 'ClaudeSDK';
repository: 'github://punt-labs/anthropic-sdk-pharo:v0.7.0/src';
load.Requires Pharo 12 (x86_64 or arm64). No external dependencies beyond Pharo's built-in Zinc HTTP and STONJSON.
| client response |
client := ClaudeClient apiKey: 'sk-ant-api03-...'.
response := client sendMessage: (ClaudeMessageRequest new
model: ClaudeModel sonnet45;
maxTokens: 1024;
addUserMessage: 'Write a haiku about Smalltalk.';
yourself).
Transcript show: response textContent; cr.ClaudeClient takes the key directly and is storage-agnostic —
ClaudeClient apiKey: 'sk-ant-...' — so library code sources the key however it
likes. For scripts, examples, and integration tests,
ClaudeSDKExampleSupport resolveClient resolves one for you by walking a
documented ladder, most-specific first, environment variable before keyring
within each tier:
| Tier | Environment variable | Keyring service / account |
|---|---|---|
| 1. Pharo override | ANTHROPIC_PHARO_API_KEY |
anthropic / pharo-api-key |
| 2. General | ANTHROPIC_API_KEY |
anthropic / api-key |
The first slot that yields a non-empty key wins; a present-but-empty
environment variable is treated as absent and falls through. The Pharo override
lets you point a Pharo image at a different key without disturbing the
ANTHROPIC_API_KEY your other tooling uses. The SDK reads only these documented
locations — it never inspects key values, guesses your store layout, or searches.
Provision the general key in your OS keyring under the documented identity:
| Backend | Command |
|---|---|
pass (Linux) |
pass insert anthropic/api-key |
secret-tool (Linux / GNOME) |
secret-tool store --label='Anthropic API Key' service anthropic account api-key |
| macOS Keychain | security add-generic-password -U -s anthropic -a api-key -w |
Never hard-code a key in source.
| client request |
client := ClaudeSDKExampleSupport resolveClient.
request := ClaudeMessageRequest new
model: ClaudeModel sonnet45;
maxTokens: 512;
addUserMessage: 'Count to five.';
yourself.
client streamMessage: request do: [ :event |
(event at: 'event') = 'content_block_delta' ifTrue: [
Transcript show: ((event at: 'data') at: 'delta') at: 'text' ] ].| request |
request := ClaudeMessageRequest new
model: ClaudeModel sonnet45;
maxTokens: 1024;
addTool: (ClaudeTool
name: 'get_weather'
description: 'Get current weather for a city.'
inputSchema: (ClaudeToolInputSchema object
required: #('city')
properties: { 'city' -> (ClaudeToolInputSchema string description: 'City name') }));
addUserMessage: 'What is the weather in Paris?';
yourself."Enable web search and bash (Anthropic runs these — no local execution)"
request addWebSearch; addBash.| client meta |
client := ClaudeSDKExampleSupport resolveClient.
meta := client uploadFile: '/path/to/report.pdf' filename: 'report.pdf' mimeType: 'application/pdf'.
Transcript show: 'File ID: ', meta fileId; cr.request mcpServers: {
ClaudeMCPServerDefinition name: 'my-server' url: 'https://mcp.example.com/sse' }.
request betas: { ClaudeBetaHeader mcpClient }.| Package | Contents |
|---|---|
Claude-Messaging-Types |
Domain hierarchy: messages, content blocks, tools, models |
Claude-Messaging-Errors |
ClaudeApiError hierarchy keyed on HTTP status |
Claude-Messaging-Streaming |
SSE decoder + raw TLS socket streaming |
Claude-Messaging-Client |
ClaudeClient — entry point for all API calls |
Claude-Messaging-Tools |
Server-side tool definitions (Anthropic-side execution) |
Claude-Messaging-Files |
Files API — upload, download, list, delete |
Claude-Messaging-MCP |
MCP connector — request-side server definitions |
Claude-Messaging-Skills |
Skills API — upload reusable tool packages |
Claude-Messaging-Batches |
Message Batches API — create, poll, and stream results (ClaudeBatch* types + ClaudeClient extensions) |
Claude-Messaging-Examples |
Runnable usage examples |
PharoKeyring |
Cross-platform OS keyring resolver (read-only) for API keys — pass, secret-tool, or macOS Keychain |
git clone git@github.com:punt-labs/anthropic-sdk-pharo.git anthropic-sdk-pharo
cd anthropic-sdk-pharo
make setup # download Pharo 12 + load packages
make start # start eval server on port 8422
make test # run test suite
make lint # zero findings requiredSee CONTRIBUTING.md and CLAUDE.md.
Full API specification: claude-sdk-specification.pdf (also available as a GitHub Release asset).
Version increments and planned API surface: see ROADMAP.md.
This project is licensed under the MIT License. See the LICENSE file for details.