@standardagents/cerebras
v0.36.3
Published
Cerebras provider for Standard Agents
Readme
@standardagents/cerebras
Cerebras provider for Standard Agents.
This package wraps Cerebras' OpenAI-compatible Chat Completions API behind the Standard Agents provider interface. It supports:
- streaming and non-streaming text generation
- local function tool calling on supported models
- JSON and structured output modes
- Cerebras reasoning controls
- usage normalization and provider-owned cost calculation for documented models
Install
npm install @standardagents/cerebras @standardagents/specUsage
import { cerebras } from '@standardagents/cerebras';
const provider = cerebras({
apiKey: process.env.CEREBRAS_API_KEY!,
});
const result = await provider.generate({
model: 'zai-glm-4.7',
messages: [{ role: 'user', content: 'Give me three concise launch names.' }],
});
console.log(result.content);
console.log(result.usage?.cost);Factory
The package exports:
cerebras(config)- provider factoryCerebrasProvider- provider classcerebrasProviderOptions- Zod schema for provider-specific options
Pricing Helpers
Known Cerebras model pricing is available through both the package root and the
pure @standardagents/cerebras/pricing subpath:
import { calculateCerebrasUsageCost } from '@standardagents/cerebras/pricing';
const cost = calculateCerebrasUsageCost('zai-glm-4.7', {
promptTokens: 6298,
completionTokens: 284,
});For known models, generated and streamed responses attach the same value to
usage.cost. Custom or private Cerebras models should still define explicit
model pricing in AgentBuilder because unknown provider prices are not guessed.
