Feixiaohao AIDocs
Product GuideTrading & SecurityListing & TrustDeveloper API
Open AIAI
Docs Home
Product Guide
  • Quick StartStart
  • Research & Data Standards
  • Explore & News
  • Alerts, Review & AI Studio
  • Account, Fei Diamonds & AI Memory
  • Community, Articles & Clubs
  • Live Streams & Red Packets
  • Events, FXH ID & Fei Diamonds
Trading & Security
  • Trading Overview
  • Wallets & Fund SecurityCore
Listing & Trust
  • Get Listed & Updates
  • FAQ
  • Terms & Risk Disclosure
  • Changelog
Developer API
  • API Quick Start & AuthAllowlist
  • Chat, Vision & Conversations
  • TTS Audio & AI Images
  • Errors, Limits & Code Examples
Back to Feixiaohao AI
Docs/Developer API/Errors, Limits & Code Examples

Errors, Limits & Code Examples

Complete HTTP and SSE error reference, default rate limits and daily quotas, retry guidelines, and production Node.js, TypeScript, and Python examples.

Updated 2026-12-02
Ask Feixiaohao AI
Note

The Developer API is currently allowlist-only. Synchronous HTTP errors always return {"error":{"code":"...","message":"..."}}. Always branch application logic and localized user copy on error.code, never on error.message.

Synchronous HTTP Error Codes

Common, Auth & Chat

HTTPcodeCauseRetryable
400EMPTY_BODY / INVALID_JSONEmpty body or malformed JSONNo
400VISION_UNAVAILABLEimages provided while vision model is disabledNo
401UNAUTHORIZED / PARTNER_SESSION_CHANGEDMissing/invalid key, disabled tenant, or key revoked mid-runNo
402PARTNER_BALANCE_EXHAUSTEDInsufficient tenant balance under metered billingNo
403CHANNEL_DISABLEDAPI channel is not enabled for this tenantNo
403CAPABILITY_DISABLEDRequested sub-capability (vision, history, TTS, image) is disabledNo
404CONVERSATION_NOT_FOUND / RUN_NOT_FOUNDMissing or cross-user/cross-tenant conversation or runNo
409RUN_ACTIVE / DUPLICATE_REQUEST / ARCHIVEDActive run in conversation, request_id conflict, or archived threadNo
413BODY_TOO_LARGE / IMAGE_TOO_LARGERequest body or image payload exceeds ceilingNo
415IMAGE_FORMATSniffed image format is not in the allowed listNo
422INVALID_REQUEST / INVALID_IMAGEInvalid parameters, unknown JSON field, or invalid image encodingNo
429RATE_LIMITED / DAILY_LIMIT_REACHEDConcurrency, per-minute rate, or UTC+8 daily quota exceededBackoff on rate limit
429SESSION_LIMIT / THREAD_LIMIT / ACCOUNT_QUOTA_EXHAUSTEDActive thread cap, 100-message cap, or user metered quota reachedNo
503SERVICE_RESTARTING / MODEL_UNAVAILABLERolling restart or temporary model unavailabilityYes (reuse request_id, fail over)
500 / 502INTERNAL_ERROR / terminal errorsGateway 502 may fail over; business 502 with error.run_id needs new request_idDepends

TTS Audio & AI Image Specific

ScopeHTTPcodeCauseRetryable
Audio400 / 422SPEECH_TEXT_INVALID / SPEECH_VOICE_INVALIDEmpty prose after cleanup, > 600 chars, or invalid voiceNo
Audio429SPEECH_BUSYTemporary upstream TTS contentionYes (backoff)
Audio503 / 502 / 504SPEECH_NOT_CONFIGURED / SPEECH_UPSTREAM_FAILED / SPEECH_TIMEOUTTTS disabled, upstream failure, or timeoutBackoff on 502/504
Image413 / 422IMAGE_REFERENCE_TOO_LARGE / IMAGE_SPEC_UNSUPPORTED / IMAGE_EDIT_UNSUPPORTED / IMAGE_PROVIDER_REJECTEDReference too large, unsupported spec/edit, or prompt rejectedNo
Image429IMAGE_PLATFORM_CONCURRENCY / IMAGE_PROVIDER_LIMIT / IMAGE_PLATFORM_BUDGETImage queue saturated or platform daily budget reachedBackoff on queue busy
Image503 / 502IMAGE_PROVIDER_DISABLED / IMAGE_GENERATION_FAILED / IMAGE_INVALID_OUTPUTImage service disabled, timeout, or invalid outputBackoff on 502

SSE error & Sync 502 Terminal Codes

CANCELLED (stopped or disconnected, do not retry), TIMEOUT (> 600 s), SERVICE_RESTART, EMPTY_RESPONSE / INCOMPLETE_RESPONSE, SAVE_FAILED / ANSWER_SETUP_FAILED / ANSWER_FAILED (generate a new request_id before retrying).

Use exponential backoff 2s -> 5s -> 10s (with +/-20% jitter, up to 3 attempts) for retryable errors.

Default Limits & Quotas (UTC+8)

ModuleLimitDefault Ceiling
Chatmessage length / images count & size8,000 chars / up to 3 images (<= 5 MB each, <= 15 MB total)
ChatRequest body size64 KB text-only / 24 MB with images
ChatTenant concurrency / per min / per day / per user per min20 / 60 / 5,000 / 12
HistoryActive threads per user / messages per thread / run timeout100 / 100 / 600 s (suggestions up to 10 s)
TTSInput text / tenant concurrency / per min / per day / per user per min600 chars / 4 / 30 / 1,000 / 15
ImagesPrompt / references / tenant concurrency / tenant per day / user per day6,000 chars / up to 3 (8 MB each, 20 MB total) / 1 / 50 / 10
PolishTenant per min / per user per min30 / 12
Tip

Default ceilings can be adjusted per allowlisted tenant. done.usage reports main-turn input_tokens, cached_tokens, output_tokens, tool_calls, and web_searches.

Reference Code

TypeScript Universal SSE Parser

ts
export async function readPartnerStream(
  response: Response,
  handlers: {
    meta?: (d: { conversation_id: string; run_id: string | null; request_id: string }) => void;
    delta?: (d: { text: string }) => void;
    done?: (d: { conversation_id: string; text: string; suggestions: string[]; usage: unknown }) => void;
    error?: (d: { code: string; message: string; text?: string }) => void;
  },
) {
  if (!response.body) throw new Error("EMPTY_STREAM_BODY");
  const reader = response.body.getReader();
  const decoder = new TextDecoder();
  let buffer = "";

  const dispatch = (block: string) => {
    let eventName = "";
    const dataLines: string[] = [];
    for (const line of block.split(/\r?\n/)) {
      if (!line || line.startsWith(":")) continue;
      if (line.startsWith("event:")) eventName = line.slice(6).trim();
      else if (line.startsWith("data:")) dataLines.push(line.slice(5).trimStart());
    }
    if (!eventName || !dataLines.length) return;
    const payload = JSON.parse(dataLines.join("\n"));
    if (eventName === "meta") handlers.meta?.(payload);
    else if (eventName === "delta") handlers.delta?.(payload);
    else if (eventName === "done") handlers.done?.(payload);
    else if (eventName === "error") handlers.error?.(payload);
  };

  try {
    for (;;) {
      const { value, done } = await reader.read();
      if (value) buffer += decoder.decode(value, { stream: true });
      let idx: number;
      while ((idx = buffer.search(/\r?\n\r?\n/)) >= 0) {
        const block = buffer.slice(0, idx);
        buffer = buffer.slice(idx).replace(/^\r?\n\r?\n/, "");
        dispatch(block);
      }
      if (done) {
        buffer += decoder.decode();
        if (buffer.trim()) dispatch(buffer);
        break;
      }
    }
  } finally {
    reader.releaseLock();
  }
}

Python Failover, Chat & Image Generation Example

python
import base64
import os
import uuid
import requests

API_BASES = [
    "https://feixiaohao.io/api/partner/v1",
    "https://fxh.one/api/partner/v1",
]
AUTH = {"Authorization": f"Bearer {os.environ['PARTNER_API_KEY']}"}


def request_failover(method: str, path: str, *, json_body=None, stream=False, timeout=(20, 660)):
    last_exc = None
    for i, base in enumerate(API_BASES):
        try:
            r = requests.request(
                method,
                f"{base}{path}",
                headers=AUTH,
                json=json_body,
                stream=stream,
                allow_redirects=False,
                timeout=timeout,
            )
            if 300 <= r.status_code < 400:
                r.close()
                last_exc = RuntimeError(f"Unexpected redirect {r.status_code}")
                continue
            if r.status_code in (502, 503, 504) and i < len(API_BASES) - 1:
                if "application/json" not in r.headers.get("Content-Type", ""):
                    r.close()
                    continue
                err = (r.json() or {}).get("error", {})
                if not err.get("run_id") and err.get("code") in (None, "SERVICE_RESTARTING", "MODEL_UNAVAILABLE"):
                    r.close()
                    continue
            return r
        except requests.RequestException as exc:
            last_exc = exc
    raise RuntimeError(f"All API bases failed: {last_exc}")


def ask_once(user_id: str, message: str):
    body = {"user_id": user_id, "message": message, "request_id": str(uuid.uuid4()), "stream": False}
    with request_failover("POST", "/chat", json_body=body) as r:
        return r.status_code, r.json()


def generate_image(prompt: str, out_file: str):
    body = {"prompt": prompt, "style": "minimal-fintech", "aspect_ratio": "landscape", "response_format": "b64_json"}
    with request_failover("POST", "/images/generations", json_body=body, timeout=(20, 270)) as r:
        data = r.json()
        if r.status_code != 200:
            raise RuntimeError(data.get("error", {}))
        with open(out_file, "wb") as f:
            f.write(base64.b64decode(data["b64_json"]))
        return {k: v for k, v in data.items() if k != "b64_json"}
PreviousTTS Audio & AI Images
AI responses are informational only and do not constitute investment advice.
TermsRisk Disclosurellms.txt
On this page
  • Synchronous HTTP Error Codes
  • Common, Auth & Chat
  • TTS Audio & AI Image Specific
  • SSE error & Sync 502 Terminal Codes
  • Default Limits & Quotas (UTC+8)
  • Reference Code
  • TypeScript Universal SSE Parser
  • Python Failover, Chat & Image Generation Example
Quick Actions
Ask Feixiaohao AI