Skip to content

API 地址

Mirrorstages 为各模型厂商提供原生协议兼容的 API 接口。使用对应厂商的官方 SDK,只需将 Base URL 指向 Mirrorstages 即可接入。

Base URL

协议地址
OpenAI 模型https://api.mirrorstages.com/openai/v1
Anthropic 模型https://api.mirrorstages.com/anthropic/v1

请求示例

OpenAI 兼容

python
from openai import OpenAI

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.mirrorstages.com/v1"
)

response = client.responses.create(
    model="claude-sonnet-4-6-20250514",
    input="Hello!"
)
print(response.output_text)
go
package main

import (
	"context"
	"fmt"

	"github.com/openai/openai-go"
	"github.com/openai/openai-go/option"
)

func main() {
	client := openai.NewClient(
		option.WithAPIKey("your-api-key"),
		option.WithBaseURL("https://api.mirrorstages.com/v1"),
	)

	response, _ := client.Responses.New(context.Background(),
		openai.ResponseNewParams{
			Model: "claude-sonnet-4-6-20250514",
			Input: openai.ResponseNewParamsInputUnion{
				OfString: openai.String("Hello!"),
			},
		},
	)
	fmt.Println(response.OutputText)
}
bash
curl https://api.mirrorstages.com/v1/responses \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6-20250514",
    "input": "Hello!"
  }'

Anthropic 兼容

python
import anthropic

client = anthropic.Anthropic(
    api_key="your-api-key",
    base_url="https://api.mirrorstages.com"
)

message = client.messages.create(
    model="claude-sonnet-4-6-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}]
)
print(message.content[0].text)
go
package main

import (
	"context"
	"fmt"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/option"
)

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("your-api-key"),
		option.WithBaseURL("https://api.mirrorstages.com"),
	)

	message, _ := client.Messages.New(context.Background(),
		anthropic.MessageNewParams{
			Model:     "claude-sonnet-4-6-20250514",
			MaxTokens: 1024,
			Messages: []anthropic.MessageParam{
				anthropic.NewUserMessage(
					anthropic.NewTextBlock("Hello!"),
				),
			},
		},
	)
	fmt.Println(message.Content[0].Text)
}
bash
curl https://api.mirrorstages.com/v1/messages \
  -H "x-api-key: your-api-key" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6-20250514",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'