小胖丸API

小胖丸API

Integration docs

Connect your preferred tools to the 小胖丸API endpoint.

01

Before you connect

Start in 1 minute: sign in, create an API key, copy it once, save it, and send the first request.

  • Open the console and sign in at https://sub.xiaopangwan.site. The console address and the API Base URL are different addresses with different jobs.
  • New here? Register at the same console first, then return to API Keys.
  • Open API Keys and create a key. Copy it immediately after creation; the full key is normally shown only once. Save it in a password manager or server-side environment variable. This guide never shows a real key.
  • Create separate keys for separate devices or clients. Revoke an old key from the API Keys page and update local environment variables when rotating credentials.
  • Check Models & pricing or GET /v1/models for models visible to your account, then replace MODEL_ID in every sample.
  • Keep keys in a password manager, operating-system key store, or local environment variable—never in browser code, screenshots, repositories, or chat transcripts.
02

Quick start

OpenAI-compatible clients always use https://api.xiaopangwan.site/v1; the console at https://sub.xiaopangwan.site is a separate address.

Raw curl requests use the complete URL. For OpenAI SDKs, set baseURL/base_url to /v1 and do not add another /v1 in method calls.

Shared headers: OpenAI uses Authorization: Bearer your_api_key and Content-Type: application/json; Claude-compatible HTTP uses x-api-key, anthropic-version: 2023-06-01, and Content-Type: application/json; Gemini HTTP uses x-goog-api-key and Content-Type: application/json.

The Claude-compatible HTTP request path is /v1/messages. Do not put /v1/messages into the OpenAI Base URL.

Request GET /v1/models first. After receiving a JSON model list, put one returned ID into the minimal request. Chat Completions returns choices, Responses returns output, Claude Messages returns content, and streaming requests return SSE events. A successful response should contain the result field for its protocol; do not treat HTTP 200 alone as a business-success check.

OpenAI SDK
https://api.xiaopangwan.site/v1chat/completionshttps://api.xiaopangwan.site/v1/chat/completions
Anthropic client
https://api.xiaopangwan.site/v1/messageshttps://api.xiaopangwan.site/v1/messages
Gemini client
https://api.xiaopangwan.site/v1beta/models/MODEL_ID:generateContenthttps://api.xiaopangwan.site/v1beta/models/MODEL_ID:generateContent
Minimal curl requestbash
curl "https://api.xiaopangwan.site/v1/chat/completions" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
03

First request

Complete the first verification in order: sign in, create a key, list models, then send a minimal request.

Open https://sub.xiaopangwan.site, sign in, and create an API key. Copy and save it; local configuration starts with the your_api_key and MODEL_ID placeholders, and never puts a real key in examples, repositories, or chat transcripts.

Request GET /v1/models first, replace MODEL_ID with an ID returned for the current key, then send a minimal request for the selected protocol.

A 2xx response with the selected protocol shape confirms the first request reached the API. This guide does not use a real API key for potentially billable inference requests.

If the first request fails, review Protocols and endpoints, Troubleshooting, and Security and operating guidance in that order.

04

Protocols and endpoints

These interfaces and protocols are provided. Results depend on the selected model, channel, upstream capability, and account permissions.

Protocol and endpoint details
MethodFull request URLAuthenticationKey parametersResponse
POSTOpenAI Chat CompletionsAvailablehttps://api.xiaopangwan.site/v1/chat/completions/v1/chat/completionsRequest root: https://api.xiaopangwan.siteAuthorization: Bearer your_api_keymodel and messages; add stream: true for SSEOpenAI-compatible choices JSON, or SSE framesContext, tools, and multimodal behavior depend on model and channel.
POSTOpenAI ResponsesAvailablehttps://api.xiaopangwan.site/v1/responses/v1/responsesRequest root: https://api.xiaopangwan.siteAuthorization: Bearer your_api_keymodel and input; add stream when neededA Responses-compatible object or event streamCodex custom providers use this endpoint; keep Base URL at /v1.
GETOpenAI ModelsAvailablehttps://api.xiaopangwan.site/v1/models/v1/modelsRequest root: https://api.xiaopangwan.siteAuthorization: Bearer your_api_keyNo request bodyModels visible to the current accountReplace MODEL_ID with an ID returned here.
POSTAnthropic MessagesAvailablehttps://api.xiaopangwan.site/v1/messages/v1/messagesRequest root: https://api.xiaopangwan.sitex-api-key plus anthropic-versionmodel, max_tokens, messages; add stream when neededAnthropic Messages-compatible blocks or event streamKeep the message shape aligned with the model protocol.
POSTAnthropic count_tokensAvailablehttps://api.xiaopangwan.site/v1/messages/count_tokens/v1/messages/count_tokensRequest root: https://api.xiaopangwan.sitex-api-key plus anthropic-versionmodel and messages, optionally system or tool fieldsAn input-token count objectThe /v1 prefix is required.
GETGemini ModelsAvailablehttps://api.xiaopangwan.site/v1beta/models/v1beta/modelsRequest root: https://api.xiaopangwan.sitex-goog-api-key: your_api_keyNo request bodyA Gemini-protocol model listGemini clients use the root Base URL.
POSTGemini generateContentAvailablehttps://api.xiaopangwan.site/v1beta/models/MODEL_ID:generateContent/v1beta/models/MODEL_ID:generateContentRequest root: https://api.xiaopangwan.sitex-goog-api-key: your_api_keycontents plus model-specific generationConfig fieldsA Gemini generateContent-compatible objectUse a Gemini-protocol MODEL_ID visible to the account.
POSTGemini streamGenerateContentAvailablehttps://api.xiaopangwan.site/v1beta/models/MODEL_ID:streamGenerateContent?alt=sse/v1beta/models/MODEL_ID:streamGenerateContent?alt=sseRequest root: https://api.xiaopangwan.sitex-goog-api-key: your_api_keycontents with the alt=sse query parameterA server-sent event streamConsume events incrementally and handle terminal/error events.
POSTImage generationsAvailablehttps://api.xiaopangwan.site/v1/images/generations/v1/images/generationsRequest root: https://api.xiaopangwan.siteAuthorization: Bearer your_api_keyOnly verified fields are documented: model=gpt-image-2, prompt, n, size, and qualityAn OpenAI image response shapeOutput specifications depend on model, channel, and permissions.
POSTImage editsAvailablehttps://api.xiaopangwan.site/v1/images/edits/v1/images/editsRequest root: https://api.xiaopangwan.siteAuthorization: Bearer your_api_keymultipart model=gpt-image-2, image, prompt, n, size, and qualityAn OpenAI image-edit response shapeUse the currently verified input fields; this guide does not infer unverified value sets.
05

Client setup

Each client assembles URLs differently. Copy the placeholder configuration, then set the key and MODEL_ID in your local environment.

Codex

Available
Request root
https://api.xiaopangwan.site/v1
Configuration fields
model_provider · base_url · env_key · wire_api = "responses"
Recommended test
Set the environment variable, then start Codex with a short prompt; the first call sends a real request.
Common mistake
Do not append /responses to base_url or put the key in a configuration file that may be committed.
Codexconfig
# Set XIAOPANGWAN_API_KEY=your_api_key in your environment first.
model = "MODEL_ID"
model_provider = "xiaopangwan"

[model_providers.xiaopangwan]
name = "小胖丸API"
base_url = "https://api.xiaopangwan.site/v1"
env_key = "XIAOPANGWAN_API_KEY"
wire_api = "responses"

Node.js(OpenAI SDK)

Available
Request root
https://api.xiaopangwan.site/v1
Configuration fields
baseURL · apiKey · model
Recommended test
Call client.models.list() first, then use a returned model ID for a minimal request.
Common mistake
baseURL already includes /v1; adding another /v1 produces the wrong path.
Node.js(OpenAI SDK)config
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.xiaopangwan.site/v1',
  apiKey: process.env.XIAOPANGWAN_API_KEY
});

const result = await client.chat.completions.create({
  model: process.env.MODEL_ID ?? 'MODEL_ID',
  messages: [{role: 'user', content: 'Hello'}],
});

console.log(result.choices[0]?.message);

OpenAI Python SDK

Available
Request root
https://api.xiaopangwan.site/v1
Configuration fields
base_url · api_key · model
Recommended test
Run client.models.list() first, then send one short message.
Common mistake
A custom environment-variable name is fine, but the shell and code must use the same name.
OpenAI Python SDKconfig
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.xiaopangwan.site/v1",
    api_key=os.environ["XIAOPANGWAN_API_KEY"],
)

result = client.chat.completions.create(
    model=os.environ.get("MODEL_ID", "MODEL_ID"),
    messages=[{"role": "user", "content": "Hello"}],
)

print(result.choices[0].message)

curl

Available
Request root
https://api.xiaopangwan.site/v1
Configuration fields
Authorization: Bearer · Content-Type · model
Recommended test
Request GET /v1/models, then put a returned model ID into the minimal request.
Common mistake
Raw HTTP calls use the complete endpoint; keep the space after Bearer.
curlconfig
curl "https://api.xiaopangwan.site/v1/chat/completions" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
06

Code examples

The samples cover regular requests, Responses, Anthropic Messages, Gemini, and both OpenAI SDKs. Every key and model is a placeholder.

curl · Chat Completionsbash
curl "https://api.xiaopangwan.site/v1/chat/completions" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
curl · Responsesbash
curl "https://api.xiaopangwan.site/v1/responses" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "input": "Hello"
  }'
curl · Model listbash
curl "https://api.xiaopangwan.site/v1/models" \
  -H "Authorization: Bearer your_api_key"
Node.js · Chat Completionsjs
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.xiaopangwan.site/v1',
  apiKey: process.env.XIAOPANGWAN_API_KEY
});

const result = await client.chat.completions.create({
  model: process.env.MODEL_ID ?? 'MODEL_ID',
  messages: [{role: 'user', content: 'Hello'}],
});

console.log(result.choices[0]?.message);
Node.js · Responsesjs
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.xiaopangwan.site/v1',
  apiKey: process.env.XIAOPANGWAN_API_KEY
});

const result = await client.responses.create({
  model: process.env.MODEL_ID ?? 'MODEL_ID',
  input: 'Hello',
});

console.log(result.output_text);
Python · Chat Completionspython
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.xiaopangwan.site/v1",
    api_key=os.environ["XIAOPANGWAN_API_KEY"],
)

result = client.chat.completions.create(
    model=os.environ.get("MODEL_ID", "MODEL_ID"),
    messages=[{"role": "user", "content": "Hello"}],
)

print(result.choices[0].message)
curl · Anthropic Messagesbash
curl "https://api.xiaopangwan.site/v1/messages" \
  -H "x-api-key: your_api_key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "max_tokens": 256,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
curl · Anthropic count_tokensbash
curl "https://api.xiaopangwan.site/v1/messages/count_tokens" \
  -H "x-api-key: your_api_key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
curl · Gemini generateContentbash
curl "https://api.xiaopangwan.site/v1beta/models/MODEL_ID:generateContent" \
  -H "x-goog-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "Hello"}]}]
  }'
07

Models and pricing

Models, prices, and account visibility can change with channels and account state, so this guide does not copy static model, price, or multiplier tables.

After signing in, treat the user center as the account source of truth. GET /v1/models returns model IDs visible to the current key.

The public Models & pricing page explains the current display policy. Actual model choice, billing, and balance changes follow the user center and request result.

A model name may be exposed through different protocols or channels. Keep the client protocol, request shape, and MODEL_ID aligned.

The only currently launched image model documented here is gpt-image-2. The openai image-only group charges per image by tier: 1K $0.50, 2K $1.00, and 4K $1.50. Do not attach gpt-image-2 to a regular plus/pro group.

08

Streaming and images

Streaming and image endpoints are provided. Fields, output specifications, and generation results depend on model, channel, upstream capability, and account permissions.

Use the Base URL https://api.xiaopangwan.site/v1 for image calls. The full image-generation URL is https://api.xiaopangwan.site/v1/images/generations, and the full image-edit URL is https://api.xiaopangwan.site/v1/images/edits. The only currently launched model is gpt-image-2.

Only verified parameters are documented: prompt, n, size, and quality. size accepts 1024x1024, 1536x1024, or 1024x1536; quality accepts auto, low, high. Do not guess background/output_format or other unverified value sets.

  • Set stream: true for OpenAI Chat Completions and Responses. Consume SSE events incrementally and handle connection loss plus the terminal event.
  • Use streamGenerateContent with alt=sse for Gemini. Add stream to the Anthropic Messages request body.
  • Image generation uses JSON; image editing uploads multipart/form-data. This guide lists only verified prompt, n, size, and quality fields; it does not infer value sets for background/output_format or other unverified fields.
  • Set connection and idle timeouts for streams, and reasonable body limits for image uploads. Do not blindly repeat potentially billable generations after a network error.
OpenAI streaming requestbash
curl "https://api.xiaopangwan.site/v1/chat/completions" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -N \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": true
  }'
Gemini streaming requestbash
curl "https://api.xiaopangwan.site/v1beta/models/MODEL_ID:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -N \
  -d '{
    "contents": [{"parts": [{"text": "Hello"}]}]
  }'
Image generationbash
curl "https://api.xiaopangwan.site/v1/images/generations" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A calm green landscape",
    "n": 1,
    "size": "1024x1024",
    "quality": "auto"
  }'
Image editbash
curl "https://api.xiaopangwan.site/v1/images/edits" \
  -H "Authorization: Bearer your_api_key" \
  -F "model=gpt-image-2" \
  -F "prompt=Refine the lighting" \
  -F "image=@input.png" \
  -F "n=1" \
  -F "size=1024x1024" \
  -F "quality=auto"
09

Troubleshooting

Record the HTTP status, protocol, and final URL first, then check credentials, model, account state, and request shape.

401

Authentication failure

Check for a missing or truncated key, the space after Bearer, and the authentication header expected by the protocol.

403

Permission or account state

Sign in and review the account state, key permissions, and permissions required by the selected channel.

404

Path or version prefix

Check the Base URL, /v1 or /v1beta, endpoint assembly, and whether the client appended a second /v1.

429

Rate, balance, or quota

Review balance and quota, reduce concurrency, and follow Retry-After or bounded exponential backoff.

BALANCE

Insufficient balance

Sign in to review balance and billing records. Top up or use an account with balance before trying once more.

CHANNEL

Channel not serving the request

Confirm the model still appears in GET /v1/models. If the model is listed but the channel is temporarily not serving requests, retry later or contact support.

TIMEOUT

Request timeout

Check network, connection, and read timeouts. Set an idle timeout for streams and avoid repeating a billable request whose first attempt may have been accepted.

5xx

Service or upstream error

Keep a redacted timestamp and status without the key. Retry later and contact service support if the condition persists.

MODEL

Model not found

Call GET /v1/models again and replace MODEL_ID with an ID returned for the current key.

PROTOCOL

Protocol and model mismatch

Confirm whether the model expects the OpenAI, Anthropic, or Gemini request shape, then use the matching endpoint.

STREAM

Streaming response issue

Confirm the client consumes SSE without buffering the full response and handles data, terminal, and disconnect events.

IMAGE

Image parameter error

Check Content-Type, multipart fields, file format and size, plus parameters accepted by the model and channel.

10

FAQ

Check the final URL and request protocol first, then review the model, authentication header, permissions, and status code.

  • Why is the URL /v1/v1 or returning 404? Give OpenAI SDKs a Base URL ending at /v1, confirm the client does not append a second /v1, and check /v1 or /v1beta plus endpoint assembly.
  • Where does MODEL_ID come from? Call GET /v1/models and replace MODEL_ID with an ID returned for the current key; visibility depends on model, channel, and account permissions. The guide does not fix model names or prices; use the user center and current request result as the source of truth.
  • Why do authentication headers differ? OpenAI uses Authorization: Bearer your_api_key; Anthropic uses x-api-key plus anthropic-version; Gemini uses x-goog-api-key.
  • Why does a streaming or image request fail? Confirm its request shape matches the model, channel, and permissions. Streaming clients must consume SSE, while image fields and formats follow parameters accepted by the model and channel.
  • How should I handle 401, 404, 429, or 5xx? Check authentication, the final URL, rate/balance/quota, or keep a redacted timestamp and status before retrying later; contact service support if 5xx persists.
  • What if a key is exposed? Sign in immediately, revoke the old key, create a replacement, and update every client and automation.
11

Security and operating guidance

Treat an API key like a password, and keep retry, concurrency, and logging policies bounded.

  • Use environment variables, an operating-system key store, or deployment secrets. Never expose a key in browser code, a repository, screenshot, or chat transcript.
  • After a leak, sign in immediately, revoke the old key, create a replacement, and update every client and automation.
  • Log only redacted request IDs, timestamps, models, status codes, and latency. Never log authentication-header values.
  • Set connection and read timeouts. Use bounded exponential backoff for 429 and recoverable 5xx responses; do not automatically retry authentication or parameter errors.
  • Before repeating a generation, edit, or other potentially billable request, determine whether the previous attempt was accepted to avoid duplicate charges.