Back to Mastra

QiHang | Models

docs/src/content/en/models/providers/qihang-ai.mdx

2025-12-184.3 KB
Original Source

QiHang

Access 9 QiHang models through Mastra's model router. Authentication is handled automatically using the QIHANG_API_KEY environment variable.

Learn more in the QiHang documentation.

bash
QIHANG_API_KEY=your-api-key
typescript
import { Agent } from "@mastra/core/agent";

const agent = new Agent({
  id: "my-agent",
  name: "My Agent",
  instructions: "You are a helpful assistant",
  model: "qihang-ai/claude-haiku-4-5-20251001"
});

// 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 QiHang documentation for details.

:::

Models

<ProviderModelsTable models={[ { "model": "qihang-ai/claude-haiku-4-5-20251001", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 64000, "inputCost": 0.14, "outputCost": 0.71 }, { "model": "qihang-ai/claude-opus-4-5-20251101", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 32000, "inputCost": 0.71, "outputCost": 3.57 }, { "model": "qihang-ai/claude-sonnet-4-5-20250929", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 64000, "inputCost": 0.43, "outputCost": 2.14 }, { "model": "qihang-ai/gemini-2.5-flash", "imageInput": true, "audioInput": true, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 1048576, "maxOutput": 65536, "inputCost": 0.09, "outputCost": 0.71 }, { "model": "qihang-ai/gemini-3-flash-preview", "imageInput": true, "audioInput": true, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 1048576, "maxOutput": 65536, "inputCost": 0.07, "outputCost": 0.43 }, { "model": "qihang-ai/gemini-3-pro-preview", "imageInput": true, "audioInput": true, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 1000000, "maxOutput": 65000, "inputCost": 0.57, "outputCost": 3.43 }, { "model": "qihang-ai/gpt-5-mini", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 64000, "inputCost": 0.04, "outputCost": 0.29 }, { "model": "qihang-ai/gpt-5.2", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 400000, "maxOutput": 128000, "inputCost": 0.25, "outputCost": 2 }, { "model": "qihang-ai/gpt-5.2-codex", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 400000, "maxOutput": 128000, "inputCost": 0.14, "outputCost": 1.14 } ]} />

Advanced configuration

Custom headers

typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://api.qhaigc.net/v1",
    id: "qihang-ai/claude-haiku-4-5-20251001",
    apiKey: process.env.QIHANG_API_KEY,
    headers: {
      "X-Custom-Header": "value"
    }
  }
});

Dynamic model selection

typescript
const agent = new Agent({
  id: "dynamic-agent",
  name: "Dynamic Agent",
  model: ({ requestContext }) => {
    const useAdvanced = requestContext.task === "complex";
    return useAdvanced
      ? "qihang-ai/gpt-5.2-codex"
      : "qihang-ai/claude-haiku-4-5-20251001";
  }
});