All examples
Language models

Connect directly to Anthropic Claude

Use the native Messages adapter with an opaque credential, explicit generation budget and reported token usage.

llm_anthropic.aner
// Configure once in Terminal: aner secrets set anthropic
// Choose a model available to your account. Checking sends no provider requests.
// Running sends one request and can incur charges; keep private keys in aner.secrets.
import aner.llm
import aner.secrets

let model = llm.client(provider: "anthropic", model: "claude-sonnet-5-5",
    key: secrets.stored("anthropic"))
// An explicitly selected file is another source: secrets.dotenv(path: ".env.local",
//     name: "ANTHROPIC_API_KEY")
// Omit temperature to preserve the provider default.
let answer = model.generate("Explain the purpose of validation data.",
    max_tokens: 1024)
print(answer.text())
print(answer.model())
print(answer.finish_reason())
print("Input tokens: " + String(answer.input_tokens()))
print("Output tokens: " + String(answer.output_tokens()))
print("Total tokens: " + String(answer.total_tokens()))
// A reported -1 means unavailable; zero is a valid reported count.

Make it your experiment.

With a compatible development runtime installed, save this program as examples/llm_anthropic.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/llm_anthropic.aner
aner run examples/llm_anthropic.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use the compatible updated native Aner development runtime with Anthropic, Gemini and expanded token usage accessors, plus matching editor integration. Checking makes no inference request and resolves no credential. Running sends one request to the configured provider and can incur charges. Choose an available model and keep the private key in aner.secrets.

Credential setup
aner secrets set anthropic
aner secrets status anthropic

Client construction and syntax checking send no inference request. Running this program calls its explicit model service. Inspect the returned finish reason and reported usage; unavailable token counts remain unknown and usage does not verify charges.

Read token accounting and provider requirements
Install Aner