본문으로 이동
CHINZYSUPER INTELLIGENCE INFRASTRUCTURE
콘솔 ↗

API 가이드

API 키 사용

2. API 키 생성 및 저장

콘솔에서 키를 만들고 월 지출 한도를 설정할 수 있습니다. 전체 키는 한 번만 표시되니 안전하게 저장하세요. 앱마다 별도 키를 쓰고 브라우저 코드나 공개 저장소에 노출하지 마세요.

3. 모델 및 프로토콜 선택

실시간 목록의 공개 별칭을 사용하세요. OpenAI 호환은 /v1, Anthropic 호환은 /anthropic을 사용합니다. 공급자 내부 ID를 플랫폼 별칭 대신 쓰지 마세요.

4. 요청 전송

SDK는 Base URL에 경로를 추가하며 curl에는 전체 URL이 필요합니다. 키를 서버 환경 변수에 저장하고 프로토콜별 인증 헤더를 보내세요. 스트리밍은 stream: true입니다.

인증 및 오류 처리

401: 키·인증 헤더 확인. 402: 잔액 확인. 403: 키 상태·월 한도 확인. 429: 지연 후 재시도. 503: 나중에 재시도하거나 사용 가능한 모델 확인.

코드의 필드명, 모델 별칭, API 경로는 개발에 사용하도록 원문을 유지합니다.

전체 기술 참조 (영어)

Getting started

Use your API key

Token Relay exposes two upstream-compatible endpoints. Once you have a key, you can keep using your existing OpenAI or Anthropic client libraries — only the base_url and the API key change.

1. Get a key

  1. Sign in to the developer console.
  2. Open API keys.
  3. Click Create API key. Give it a name (something like local-dev or prod-app) and optionally a monthly spend cap in CN¥.
  4. A token starting with tsk_ appears in the reveal banner. Copy it now — the platform never shows the full token again.
Why reveal-once? The backend only stores a SHA-256 hash of the token. Even an admin with full database access can't recover the original — they can only revoke and reissue.

2. Endpoints

The relay exposes two protocols. Pick the one your client already speaks.

ProtocolBase URLAuth header
OpenAI Chat Completionshttps://chinzy.com/v1Authorization: Bearer tsk_...
Anthropic Messages (streaming)https://chinzy.com/anthropic/v1x-api-key: tsk_...

3. Pick a model

Pass any of our public model aliases as the model field. The full list is at Models. A few common ones:

  • gpt-5.2, gpt-5, gpt-5-mini, gpt-5.4-mini — OpenAI family
  • claude-sonnet-4.5, claude-haiku-4.5, claude-opus-4.5 — Anthropic family
  • deepseek-v3.2, kimi-k2-thinking, glm-4.6 — open-weight families

You always pass the platform alias, never the upstream-specific id. Behind the scenes the relay picks a healthy upstream and routes the call there with automatic failover.

4. Examples

curl

curl https://chinzy.com/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN_RELAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.2",
    "messages": [
      {"role": "user", "content": "Hi in one sentence"}
    ]
  }'

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["TOKEN_RELAY_KEY"],
    base_url="https://chinzy.com/v1",
)

resp = client.chat.completions.create(
    model="gpt-5.2",
    messages=[{"role": "user", "content": "Hi in one sentence"}],
)
print(resp.choices[0].message.content)

Node.js (OpenAI SDK)

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.TOKEN_RELAY_KEY,
  baseURL: 'https://chinzy.com/v1',
});

const resp = await client.chat.completions.create({
  model: 'gpt-5.2',
  messages: [{ role: 'user', content: 'Hi in one sentence' }],
});
console.log(resp.choices[0].message.content);

Anthropic SDK (streaming)

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.TOKEN_RELAY_KEY,
  baseURL: 'https://chinzy.com/anthropic',
});

const stream = await client.messages.stream({
  model: 'claude-sonnet-4.5',
  max_tokens: 512,
  messages: [{ role: 'user', content: 'Hi in one sentence' }],
});

for await (const event of stream) {
  if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
    process.stdout.write(event.delta.text);
  }
}

5. Common errors

StatusMeaningFix
401Token missing, malformed, or disabled.Verify the Authorization header value matches the token from the reveal banner. Check API keys — disabled keys show a red badge.
402 / 403 "balance too low"Wallet has no balance to settle this request.Top up at Billing.
403 "monthly spend cap reached"This specific key's monthly quota is exhausted.Either wait for the next calendar month, raise the cap on API keys, or use a different key.
429You crossed the per-IP rate limit (300 req/min for relay).Backoff and retry; widen the gap between requests.
503Every upstream that serves this alias is down. Rare — the relay already auto-retries on intermittent failures.Try a sibling alias (e.g. gpt-5-mini instead of gpt-5.2). If persistent, check your status page.

6. Tips

  • One key per app. Cheap to rotate; lets you disable a leaked credential without breaking other clients.
  • Set a monthly cap. A runaway dev loop is much easier to recover from when each key is bounded.
  • Watch usage at /console/usage. The page shows per-model + per-key spend, recent calls with status codes, and a CSV export for accounting.
  • Streaming is supported on both protocols. Just pass stream: true in the OpenAI SDK or use messages.stream() with Anthropic.

Found something missing or wrong in this doc? Open an issue or ping an admin.