@mayurajs/provider-anthropic
v1.2.0
Published
Anthropic Claude models for Mayura, through the official Anthropic SDK.
Readme
@mayurajs/provider-anthropic
Anthropic Claude models for Mayura, through the official @anthropic-ai/sdk and the Messages API.
npm install mayura @mayurajs/provider-anthropicimport { createModels, defineAgent, z } from 'mayura';
import { anthropic } from '@mayurajs/provider-anthropic';
const models = createModels({
providers: [anthropic({ apiKey: process.env.ANTHROPIC_API_KEY! })],
prices: { 'anthropic/claude-sonnet-5-5': { inputMicrosPerMillionTokens: 2_000_000, outputMicrosPerMillionTokens: 10_000_000 } },
maxCallCostMicros: 50_000,
});
const agent = defineAgent({
id: 'helper', version: '1', instructions: 'Answer in one sentence.', model: models.model('anthropic/claude-sonnet-5-5'), tools: [],
input: z.object({ question: z.string() }), output: z.object({ answer: z.string() }),
});
// Grant it as model:anthropic/claude-sonnet-5-5.- Credentials are options: nothing is read from the environment.
- The SDK's own retries are off; the registry's
retryoption retries and charges every attempt. - Tool inputs and structured output use strict JSON Schema; streaming reports output text as it arrives; the model's thinking is kept for the next call and never released.
- Runs can take a conversation history (
runtime.submit(agent, { input, history })), sent before the run's own messages on every call. Tool call ids Anthropic does not take (with.or/) are sent with_in their place; when a run offers no tools, the history's tool calls and results are sent as text, since Anthropic refuses tool blocks without tools. - Prompt-cache writes are charged at twice the input rate and reads at the full rate, so a budget never undercounts.
catalogholds Anthropic's list prices on its date, used only withprices: 'catalog'.
See the model registry guide. Apache-2.0.
