Developer docs

Understand the API contract before you integrate.

A focused API surface for teams who want to move from idea to integrated experience without ceremony. Availability is always controlled by the live model catalog.

Wanyra-supported OpenAI-compatible subset

Wanyra exposes a catalog-gated OpenAI-compatible surface covering text (Chat Completions and Responses), image generation and editing, video, speech synthesis and transcription, embeddings, vision analysis, and web search. It is not a full or current mirror of the official OpenAI API; only models that pass Wanyra catalog, pricing, credential, and release checks appear in /v1/models and accept traffic.

Call /v1/models or check the live price sheet on the home page to confirm the active model IDs and current prices. Prices read directly from the billing system and take effect the same day they change.

For machine-readable integration, fetch /v1/openapi.json. It is the source of truth for public endpoints, request fields, multipart forms, responses, and errors; provider names and upstream model names are internal and are not sent by clients.

1. Quickstart

Call /v1/models to confirm available model IDs, create a production API key in the Console (store it on your server), and point your baseURL at https://api.star1age.cn/v1. Non-text generation endpoints require an Idempotency-Key header.

curl https://api.star1age.cn/v1/models \
  -H "Authorization: Bearer $STAR1AGE_API_KEY"

OpenAI JavaScript SDK

The OpenAI JavaScript SDK targets Wanyra text and image endpoints via a custom baseURL. Store your API key in a server environment variable. Image endpoints require Idempotency-Key and return HTTP 202 with status_url (poll GET /v1/requests/:id); video jobs use the multipart/form-data contract described below.

npm install openai

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.STAR1AGE_API_KEY,
  baseURL: 'https://api.star1age.cn/v1'
});

const chat = await client.chat.completions.create({
  model: 'star1age-gpt-6.2-sol',
  messages: [{role: 'user', content: 'Hello'}]
});
console.log(chat.choices[0]?.message?.content);

const image = await client.images.generate(
  {
    model: 'star1age-gpt-image-2',
    prompt: 'A cinematic city at dusk',
    size: '1024x1024',
    n: 1,
    response_format: 'url'
  },
  {headers: {'Idempotency-Key': 'image-demo-001'}}
);
console.log(image);

OpenAI Python SDK

The OpenAI Python SDK targets Wanyra text and image endpoints via base_url. Never commit API keys to source control. Image endpoints require Idempotency-Key via extra_headers and return HTTP 202 with status_url (poll GET /v1/requests/:id); video jobs use the multipart/form-data contract in the Videos section.

pip install openai

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["STAR1AGE_API_KEY"],
    base_url="https://api.star1age.cn/v1",
)

chat = client.chat.completions.create(
    model="star1age-gpt-6.2-sol",
    messages=[{"role": "user", "content": "Hello"}],
)
print(chat.choices[0].message.content)

image = client.images.generate(
    model="star1age-gpt-image-2",
    prompt="A cinematic city at dusk",
    size="1024x1024",
    n=1,
    response_format="url",
    extra_headers={"Idempotency-Key": "image-demo-001"},
)
print(image)

2. Authentication and scopes

Send a production key as Authorization: Bearer sa_live_.... Keys are shown once when created or rotated. Assign only the scopes your integration needs; the server rejects requests that lack the required scope. A scope can exist before a matching model is released; model availability is always determined by /v1/models.

Authorization: Bearer sa_live_...

Available scopes:
  models:read
  chat:generate
  responses:generate
  images:generate
  images:edit
  videos:generate
  videos:read
  audio:speech
  audio:transcribe
  web:search
  embeddings:create
  vision:analyze

3. Images

POST /v1/images/generations and POST /v1/images/edits both create durable asynchronous jobs, returning HTTP 202 with status_url immediately; poll GET /v1/requests/:id for controlled, signed asset URLs. Generation keeps an OpenAI-compatible JSON body with model, prompt, size, quality, n, response_format, negative_prompt, seed, watermark, prompt_extend, enable_interleave, and optional parameters (explicit sizes such as 1280*720 pass through verbatim). Edits use multipart/form-data uploads or owned asset IDs and do not accept external image URLs. See /v1/openapi.json for exact schemas.

# Generate an image (returns 202 with status_url; poll /v1/requests/:id)
curl https://api.star1age.cn/v1/images/generations \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: image-demo-001" \
  -d '{
    "model": "star1age-wan2.7-image-pro",
    "prompt": "A cinematic city at dusk",
    "size": "1280*720",
    "n": 1,
    "watermark": false,
    "response_format": "url"
  }'

# Edit an image (multipart upload or owned asset IDs; external URLs are not accepted)
curl https://api.star1age.cn/v1/images/edits \
  -X POST \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Idempotency-Key: image-edit-demo-001" \
  -F "model=star1age-qwen-image-edit" \
  -F "prompt=Replace the background with a clear dusk sky" \
  -F "image=@input.png"

# Poll durable request status until succeeded
curl https://api.star1age.cn/v1/requests/req_id \
  -H "Authorization: Bearer $STAR1AGE_API_KEY"

4. Videos

Wanyra exposes a Videos-compatible asynchronous multipart/form-data job contract at POST /v1/videos and requires Idempotency-Key. Poll GET /v1/videos/:id (or stream GET /v1/videos/:id/events) until status is completed, then download the asset from /content. Model IDs, resolutions, aspect ratios, durations, native parameters, accepted references, and live pricing are governed by the public catalog. HappyHorse 1.0 exposes its complete 720P/1080P, 3-15 second, nine-ratio, watermark, and seed contract. Video listing supports after, limit, and order cursor parameters.

curl https://api.star1age.cn/v1/videos \
  -X POST \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Idempotency-Key: video-demo-001" \
  -F "model=star1age-happyhorse-1.0" \
  -F "prompt=A slow aerial shot over a neon-lit city at night." \
  -F "seconds=5" \
  -F "size=1280x720"

curl https://api.star1age.cn/v1/videos/video_request_id \
  -H "Authorization: Bearer $STAR1AGE_API_KEY"

curl -L https://api.star1age.cn/v1/videos/video_request_id/content \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -o output.mp4

5. Audio, embeddings, vision, and web search

Wanyra also provides speech synthesis (POST /v1/audio/speech), audio transcription (POST /v1/audio/transcriptions), custom voice enrollment (/v1/audio/voices), text and multimodal embeddings (POST /v1/embeddings), standalone web search (POST /v1/web-search), and image/video vision analysis (POST /v1/vision/analyze). Every one of these endpoints requires an Idempotency-Key header. Speech and transcription return HTTP 202 with status_url immediately (poll GET /v1/requests/:id for the controlled audio asset or transcript). Vision analysis accepts multipart uploads or owned asset IDs only; external URLs are not accepted.

# Speech synthesis (returns 202; poll /v1/requests/:id)
curl https://api.star1age.cn/v1/audio/speech \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: speech-demo-001" \
  -d '{
    "model": "star1age-qwen-audio-3.0-tts-flash",
    "input": "Welcome to Wanyra.",
    "voice": "longanhuan_v3.6",
    "response_format": "wav"
  }'

# Audio transcription (returns 202; poll /v1/requests/:id)
curl https://api.star1age.cn/v1/audio/transcriptions \
  -X POST \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Idempotency-Key: asr-demo-001" \
  -F "model=star1age-paraformer-v2" \
  -F "file=@sample.wav"

# Embeddings
curl https://api.star1age.cn/v1/embeddings \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: emb-demo-001" \
  -d '{
    "model": "star1age-text-embedding-v4",
    "input": ["Hello Wanyra"]
  }'

# Web search
curl https://api.star1age.cn/v1/web-search \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: search-demo-001" \
  -d '{
    "model": "star1age-web-search",
    "queries": ["Wanyra OpenAI compatible API"]
  }'

# Vision analysis (multipart image/video upload or owned asset ID)
curl https://api.star1age.cn/v1/vision/analyze \
  -X POST \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Idempotency-Key: vision-demo-001" \
  -F "model=star1age-qwen3-vl-flash" \
  -F "input=Describe the main subject in one sentence." \
  -F "input_reference=@scene.jpg"

6. Errors

Errors use a structured object with message, type, param, and code. Treat 4xx responses as request or authorization problems; 5xx responses may represent a provider or temporary service failure. Preserve the x-request-id response header for support and tracing.

{
  "error": {
    "message": "Rate limit exceeded.",
    "type": "rate_limit_error",
    "param": null,
    "code": "rate_limit_exceeded"
  }
}

7. Rate limits

The API applies both API-key and IP dimensions. Read the returned headers instead of hard-coding a retry interval. When a limit is exceeded, the response is 429 and Retry-After contains the server-provided delay in seconds.

x-ratelimit-limit-key: <current-key-limit>
x-ratelimit-remaining-key: <remaining-key-requests>
x-ratelimit-limit-ip: <current-ip-limit>
x-ratelimit-remaining-ip: <remaining-ip-requests>
retry-after: <seconds>

8. Idempotency

Idempotency-Key is Wanyra’s request-deduplication header: it is required on image, video, audio, embedding, vision, and web-search endpoints, and optional on text endpoints (required when resuming a stream with Last-Event-ID). Reusing the same key for the same API key, endpoint, and payload within 24 hours returns the original result; reusing a key with a different payload returns a conflict rather than starting a second job.

Idempotency-Key: checkout-image-20261122-001

9. Text streaming

Catalog-enabled text models support resumable SSE on both POST /v1/chat/completions and POST /v1/responses. Always reuse the same Idempotency-Key when reconnecting, and send the last received SSE id as Last-Event-ID to continue from the next frame. Omitting Last-Event-ID replays the stream from the beginning. Closing the client connection does not cancel provider execution: the request continues in the background, the encrypted terminal result is retained for replay, and normal usage-based billing still applies.

# Chat Completions SSE
curl -N https://api.star1age.cn/v1/chat/completions \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: chat-stream-demo-001" \
  -d '{
    "model": "star1age-gpt-6.2-sol",
    "messages": [{"role": "user", "content": "Reply with one short sentence."}],
    "stream": true,
    "stream_options": {"include_usage": true}
  }'

# Responses SSE
curl -N https://api.star1age.cn/v1/responses \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: responses-stream-demo-001" \
  -d '{
    "model": "star1age-gpt-6.2-sol",
    "instructions": "Be concise.",
    "input": "Reply with one short sentence.",
    "stream": true
  }'

# Resume after disconnect using the same request identity
curl -N https://api.star1age.cn/v1/chat/completions \
  -H "Authorization: Bearer $STAR1AGE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: chat-stream-demo-001" \
  -H "Last-Event-ID: <last-sse-id>" \
  -d '{
    "model": "star1age-gpt-6.2-sol",
    "messages": [{"role": "user", "content": "Reply with one short sentence."}],
    "stream": true,
    "stream_options": {"include_usage": true}
  }'

10. API reference

The interactive reference below is rendered directly from /v1/openapi.json, the single source of truth for the public contract.

Loading API Reference…
Developer documentation | Wanyra