Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xhuoapi.ai/llms.txt

Use this file to discover all available pages before exploring further.

This walkthrough uses Midjourney text-to-image as the example: sign up → get a Token → call the API → read the result.

1. Sign up and grab credit

  1. Register at platform.xhuoapi.ai
  2. Open the Midjourney service detail page and purchase a package or claim a trial
  3. On the Credentials tab, click Create and copy the returned Token
The Token is a secret. Never paste it into frontend / mobile code or public repos — use env vars or a secrets manager.

2. Make the request

Export your Token:
export XHuoAPI_API_TOKEN="your-token-here"
Call text-to-image:
curl https://api.xhuoapi.ai/v1/midjourney/imagine \
  -X POST \
  -H "Authorization: Bearer $XHuoAPI_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A cute cat sitting on a wooden table, soft lighting"
  }'

3. Parse the response

/midjourney/imagine waits for generation to finish before returning (~tens of seconds), so the body already contains the result:
{
  "success": true,
  "task_id": "27a1128f-14b5-440e-a82d-510c81e6fcd4",
  "image_id": "1211290228438868029",
  "image_url": "https://midjourney.cdn.xhuoapi.ai/.../image.png",
  "image_width": 1024,
  "image_height": 1024,
  "actions": ["upscale1", "upscale2", "variation1", "variation2", "..."]
}
  • image_url is the 4-quadrant grid image — display or download it directly
  • actions lists follow-up operations you can run on this image (upscale, variations)
  • task_id is used for follow-up calls (upscale / variation)
On failure the body shape is different — it has no success field:
{
  "error": {
    "code": "invalid_token",
    "message": "The specified token is invalid or wrong."
  },
  "trace_id": "..."
}
For the full error table see Response format.

4. Async: long video / long music

Heavier video and music endpoints typically return only a task_id and deliver the result via polling or webhook. See Async task model.

5. Where to go next

API reference

Interactive docs for every endpoint

Gateway & auth

Tokens, endpoints, error codes

Pricing overview

Billing model for each category

MCP integration

Call from Claude / Cursor directly