docs/src/content/en/models/providers/stepfun.mdx
Access 3 StepFun models through Mastra's model router. Authentication is handled automatically using the STEPFUN_API_KEY environment variable.
Learn more in the StepFun documentation.
STEPFUN_API_KEY=your-api-key
import { Agent } from "@mastra/core/agent";
const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "stepfun/step-1-32k"
});
// 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);
}
:::info
Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the StepFun documentation for details.
:::
<ProviderModelsTable models={[ { "model": "stepfun/step-1-32k", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 32768, "maxOutput": 32768, "inputCost": 2.05, "outputCost": 9.59 }, { "model": "stepfun/step-2-16k", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 16384, "maxOutput": 8192, "inputCost": 5.21, "outputCost": 16.44 }, { "model": "stepfun/step-3.5-flash", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 256000, "maxOutput": 256000, "inputCost": 0.096, "outputCost": 0.288 } ]} />
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://api.stepfun.com/v1",
id: "stepfun/step-1-32k",
apiKey: process.env.STEPFUN_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});
const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "stepfun/step-3.5-flash"
: "stepfun/step-1-32k";
}
});