API Quick Start & Auth
Allowlist scope, primary and backup base URLs, Bearer authentication, failover rules, anonymous user IDs, and idempotency for the Feixiaohao AI API v1.
Updated 2026-12-02
The Feixiaohao AI API (v1) delivers server-side conversational intelligence for crypto assets, US equities and tokenized stocks, and real-time market data, along with multimodal image vision, conversation history management, text-to-speech (TTS), and AI image generation.
Core Parameters & Endpoints
| Property | Value |
|---|---|
| API Version | v1 (backward-compatible) |
| Primary Base URL | https://feixiaohao.io/api/partner/v1 |
| Backup Base URL | https://fxh.one/api/partner/v1 |
| Protocols | HTTPS (TLS 1.2+), JSON (UTF-8), SSE (text/event-stream; charset=utf-8), multipart/form-data, binary (audio/mpeg, image/png) |
| Authentication | Authorization: Bearer <API_KEY> (server-to-server only) |
| Quota & Reporting Timezone | Asia/Shanghai (UTC+8) |
| Module | Method & Path | Description |
|---|---|---|
| Chat | POST /api/partner/v1/chat | Start a turn (text plus 1-3 inline images, SSE streaming or sync JSON) |
| Chat | POST /api/partner/v1/chat/{run_id}/cancel | Stop an in-flight response |
| History | POST /api/partner/v1/conversations | Pre-create an empty conversation (optional; first turn auto-creates) |
| History | GET /api/partner/v1/conversations | List conversations for a user_id |
| History | GET /api/partner/v1/conversations/{conversation_id}/messages | Fetch sanitized message history for a conversation |
| History | DELETE /api/partner/v1/conversations/{conversation_id} | Delete an idle conversation |
| Audio | POST /api/partner/v1/audio/speech | Text-to-speech returning streamed or buffered 128 kbps MP3 |
| Audio | POST /api/partner/v1/audio/speech-with-timestamps | Text-to-speech with word-level millisecond timestamps |
| Images | POST /api/partner/v1/images/generations | AI image generation and reference editing (b64_json or binary PNG) |
| Images | POST /api/partner/v1/images/polish | Prompt polishing and creative inspiration |
Compatibility Contract
- Response objects may add optional fields over time; clients must ignore unknown fields when parsing JSON.
- JSON request bodies use strict validation and reject undefined fields with
422 INVALID_REQUEST.
Quick Start
bash
export PARTNER_API_KEY="pk_demo_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Primary base URL; switch to https://fxh.one/api/partner/v1 on network or gateway failures
export PARTNER_API_BASE="https://feixiaohao.io/api/partner/v1"
# 1) Streaming chat (default)
curl -N --max-time 660 "$PARTNER_API_BASE/chat" \
-H "Authorization: Bearer $PARTNER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "u_anon_9f2c1a8b",
"message": "What is the latest BTC price and 24h change?",
"request_id": "req-quickstart-001"
}'
# 2) Synchronous single JSON response
curl --max-time 660 "$PARTNER_API_BASE/chat" \
-H "Authorization: Bearer $PARTNER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "u_anon_9f2c1a8b",
"message": "What is the latest BTC price and 24h change?",
"request_id": "req-quickstart-002",
"stream": false
}'Authentication, Security & Failover
- Server-side only: Store the API key in backend environment variables or a KMS. Never expose it in frontend bundles, mobile binaries, public repositories, or logs. No CORS headers are emitted for browser-direct calls.
- Per-tenant sub-capability gates: Standard text chat is active whenever the API channel is enabled. Cost-bearing or extended sub-capabilities (vision, TTS, AI images) are enabled per allowlisted tenant; disabled capabilities return
403 CAPABILITY_DISABLED. - Zero-downtime rotation: Multiple active keys are supported per tenant. Revoking a key takes effect immediately and aborts active streams with
401 PARTNER_SESSION_CHANGED. - Use bare HTTPS domains and disable redirects: Always target the bare domain (never
www.) and disable automatic 3xx redirect following in your HTTP client to prevent leaking or strippingAuthorizationheaders.
Both the primary base (https://feixiaohao.io/api/partner/v1) and backup base (https://fxh.one/api/partner/v1) route to the same cluster and share keys, user_id, conversation_id, and idempotency records:
| Failure Condition | Fail Over to Backup? | request_id Handling |
|---|---|---|
| DNS/TCP/TLS failure, header timeout, disconnect before headers | Yes | Reuse original request_id on /chat |
Gateway HTTP 502 / 503 / 504 (non-JSON, or SERVICE_RESTARTING / MODEL_UNAVAILABLE) | Yes | Reuse original request_id on /chat |
Read-only GET /conversations* transient network or gateway error | Yes | Not applicable |
Sync chat business HTTP 502 (JSON contains error.run_id) | Optional | Must generate a new request_id |
HTTP 400 / 401 / 402 / 403 / 404 / 409 / 413 / 415 / 422 | No | Do not retry |
| SSE or audio stream disconnects after bytes started arriving | No | Generate a new request_id to re-ask |
Anonymous user_id & Idempotency (request_id)
user_id: 1-128 trimmed characters. Required for chat and conversation routes; optional (recommended) for audio and image routes to isolate per-user rate limits. Use a stable irreversible identifier such asHMAC-SHA256of your internal UID; never pass plain PII such as phone numbers, emails, or real names.conversation_id: Standard UUID. Omit on the first turn to auto-create and pass back on follow-ups. Each user may hold up to 100 active conversations (oldest idle archived automatically) and 100 messages per conversation; only 1 active run is allowed per conversation at a time.request_id(POST /chatidempotency key): Recommended UUID v4 (1-100 chars matching^[A-Za-z0-9_-]+$). Replays verify exact consistency acrossuser_id,message(plus SHA-256 digests of any attached images), andconversation_id:- Previous status
completed: Replays the original answer with"replayed": true(SSE replays omitid:lines). - Previous status
running: Returns409 RUN_ACTIVE. - Previous status
failed/cancelled, or mismatched payload: Returns409 DUPLICATE_REQUEST(use a freshrequest_id).
- Previous status