Skip to main content

Cortecs logoCortecs

Access 10 Cortecs models through Mastra's model router. Authentication is handled automatically using the CORTECS_API_KEY environment variable.

Learn more in the Cortecs documentation.

CORTECS_API_KEY=your-api-key
import { Agent } from "@mastra/core";

const agent = new Agent({
name: "my-agent",
instructions: "You are a helpful assistant",
model: "cortecs/claude-sonnet-4",
});

// 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);
}
OpenAI Compatibility

Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Cortecs documentation for details.

Models

ModelImageAudioVideoToolsStreamingContext Window
cortecs/nova-pro-v1300,000
cortecs/deepseek-v3-0324128,000
cortecs/kimi-k2-instruct131,000
cortecs/gpt-4.11,047,576
cortecs/gemini-2.5-pro1,048,576
cortecs/gpt-oss-120b128,000
cortecs/qwen3-coder-480b-a35b-instruct262,000
cortecs/claude-sonnet-4200,000
cortecs/llama-3.1-405b-instruct128,000
cortecs/qwen3-32b16,384

Advanced Configuration

Custom Headers

const agent = new Agent({
name: "custom-agent",
model: {
url: "https://api.cortecs.ai/v1",
modelId: "claude-sonnet-4",
apiKey: process.env.CORTECS_API_KEY,
headers: {
"X-Custom-Header": "value",
},
},
});

Dynamic Model Selection

const agent = new Agent({
name: "dynamic-agent",
model: ({ runtimeContext }) => {
const useAdvanced = runtimeContext.task === "complex";
return useAdvanced
? "cortecs/qwen3-coder-480b-a35b-instruct"
: "cortecs/claude-sonnet-4";
},
});