--- title: "SparrowCodes Models: IDs, Pricing & Usage" description: "Browse SparrowCodes model IDs, capabilities, context windows, and pricing. Learn how to use them in TypeScript with Mastra's model router." --- {/* This file is auto-generated by generate-model-docs.ts - DO NOT EDIT MANUALLY */} # SparrowCodes logoSparrowCodes Access 19 SparrowCodes models through Mastra's model router. Authentication is handled automatically using the `SPARROWCODES_API_KEY` environment variable. Learn more in the [SparrowCodes documentation](https://sparrowcodes.com/models). ```bash title=".env" SPARROWCODES_API_KEY=your-api-key ``` ```typescript title="src/mastra/agents/my-agent.ts" {7} import { Agent } from "@mastra/core/agent"; const agent = new Agent({ id: "my-agent", name: "My Agent", instructions: "You are a helpful assistant", model: "sparrowcodes/anthropic/claude-fable-5.1" }); // Generate a response const response = await agent.generate("Hello!"); // Stream a response const stream = await agent.stream("Tell me a story"); for await (const chunk of stream) { console.log(chunk); } ``` :::note Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [SparrowCodes documentation](https://sparrowcodes.com/models) for details. ::: ## Models Model availability, capabilities, context windows, and pricing are sourced from [models.dev](https://models.dev) and may change. ## Advanced configuration ### Custom headers ```typescript title="src/mastra/agents/my-agent.ts" import { Agent } from "@mastra/core/agent"; const agent = new Agent({ id: "custom-agent", name: "custom-agent", model: { url: "https://api.sparrowcodes.com/v1", id: "sparrowcodes/anthropic/claude-fable-5.1", apiKey: process.env.SPARROWCODES_API_KEY, headers: { "X-Custom-Header": "value" } } }); ``` ### Dynamic model selection ```typescript title="src/mastra/agents/my-agent.ts" import { Agent } from "@mastra/core/agent"; const agent = new Agent({ id: "dynamic-agent", name: "Dynamic Agent", model: ({ requestContext }) => { const useAdvanced = requestContext.task === "complex"; return useAdvanced ? "sparrowcodes/z-ai/glm-5.3-flash" : "sparrowcodes/anthropic/claude-fable-5.1"; } }); ```