Runnable integration examples

Choose one operation, inspect its request, then run it with your own key. The Python and Node.js clients need no third-party dependencies.

Download and prepare

Download the example package and extract it. Python 3.10+ or Node.js 22+ is required. These are reference clients, not a separately maintained SDK.

Download Python + Node.js examples · Request fixtures (JSON)

# Bash — do not paste your key into source or a shared terminal
export KEYO_API_KEY="YOUR_KEY"
# Windows PowerShell
$env:KEYO_API_KEY = "YOUR_KEY"

# Dry-run: prints the request; sends nothing
python python/keyoapi_example.py image
node node/keyoapi-example.mjs image

Check the model ID, available API-key group, parameters and current rate in the catalog. A --run command can charge your wallet. Running one scenario never automatically submits another.

Chat

gpt-6-luna · POST /v1/chat/completions

Send one short text request. Streaming and tool fields depend on the selected model.

Request parameters
{
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Say hello in one sentence."
    }
  ],
  "max_tokens": 128
}
python python/keyoapi_example.py chat --run
# or
node node/keyoapi-example.mjs chat --run
Illustrative successful result
{
  "choices": [
    {
      "message": {
        "content": "Example text"
      }
    }
  ]
}

Image generation

gpt-image-2.5-flare · POST /v1/images/generations → GET /v1/images/tasks/{id}

Asynchronous image generation. Save the receipt and query the image-specific path until a result URL is available.

Request parameters
{
  "model": "gpt-image-2.5-flare",
  "prompt": "An orange cat on a sunny windowsill",
  "size": "1024x1024",
  "n": 1,
  "response_format": "url",
  "replyType": "async"
}
python python/keyoapi_example.py image --run
# or
node node/keyoapi-example.mjs image --run
Illustrative successful result
{
  "status": "succeeded",
  "data": [
    {
      "url": "https://example.invalid/result.png"
    }
  ]
}

Video generation

wan3.0-video · POST /v1/videos/generations → GET /v1/tasks/{id}

Video duration is 5 seconds at 720P for this fixture. Inspect model-specific duration, reference and resolution limits before changing it.

Request parameters
{
  "model": "wan3.0-video",
  "prompt": "A red paper boat drifting on calm water at sunset",
  "resolution": "720P",
  "duration": 5
}
python python/keyoapi_example.py video --run
# or
node node/keyoapi-example.mjs video --run
Illustrative successful result
{
  "status": "completed",
  "url": "https://example.invalid/result"
}

Speech synthesis

Spark-TTS-0.5B · POST /v1/async/audio/speech → GET /v1/task/{id}

Basic asynchronous speech generation. Voice cloning is a different mode and needs a permitted reference recording and its documented fields.

Request parameters
{
  "model": "Spark-TTS-0.5B",
  "inputs": "Hello, welcome to KeyoAPI",
  "gender": "male",
  "pitch": 3,
  "speed": 3
}
python python/keyoapi_example.py tts --run
# or
node node/keyoapi-example.mjs tts --run
Illustrative successful result
{
  "status": "completed",
  "url": "https://example.invalid/result"
}

Transcription

SenseVoiceSmall · POST /v1/audio/transcriptions

Provide sample.wav. Transcription returns text; the public rate is per request for this model.

Request parameters
{
  "fields": {
    "model": "SenseVoiceSmall"
  },
  "files": {
    "file": "sample.wav"
  }
}
python python/keyoapi_example.py asr --run
# or
node node/keyoapi-example.mjs asr --run
Illustrative successful result
{
  "text": "Example transcription"
}

Document parsing

MinerU2.5-Pro · POST /v1/async/documents/parse → GET /v1/task/{id}

Provide document.pdf. Submission starts a document task; successful receipt alone does not mean parsing is finished.

Request parameters
{
  "fields": {
    "model": "MinerU2.5-Pro"
  },
  "files": {
    "file": "document.pdf"
  }
}
python python/keyoapi_example.py document --run
# or
node node/keyoapi-example.mjs document --run
Illustrative successful result
{
  "status": "completed",
  "text": "Example extracted text"
}

Vision tools

RMBG-2.0 · POST /v1/images/mattings

Provide photo.png. Background removal uses multipart image, not a chat prompt. Inspect the returned URL or image response.

Request parameters
{
  "fields": {
    "model": "RMBG-2.0"
  },
  "files": {
    "image": "photo.png"
  }
}
python python/keyoapi_example.py vision --run
# or
node node/keyoapi-example.mjs vision --run
Illustrative successful result
{
  "status": "completed",
  "url": "https://example.invalid/result"
}

Digital humans

InfiniteTalk · POST /v1/async/videos/image-to-video → GET /v1/task/{id}

Provide portrait.png and speech.wav; InfiniteTalk audio must be 15 seconds or shorter. Use your own or authorized likeness and recording.

Request parameters
{
  "fields": {
    "model": "InfiniteTalk",
    "prompt": "A person speaking naturally to camera, keeping identity and background stable"
  },
  "files": {
    "cond_video": "portrait.png",
    "cond_audio": "speech.wav"
  }
}
python python/keyoapi_example.py avatar --run
# or
node node/keyoapi-example.mjs avatar --run
Illustrative successful result
{
  "status": "completed",
  "url": "https://example.invalid/result"
}

Reference-image editing

gpt-image-2.5-flare · POST /v1/images/edits → GET /v1/images/tasks/{id}

Place reference.png beside the command, or set KEYO_INPUT_DIR. The image field carries the actual file bytes. Preserve composition and subject when asking for line art.

Request parameters
{
  "fields": {
    "model": "gpt-image-2.5-flare",
    "prompt": "Turn the reference image into a clean black line drawing on a white background. Preserve its composition and subject.",
    "size": "1024x1024",
    "n": "1",
    "replyType": "async"
  },
  "files": {
    "image": "reference.png"
  }
}
python python/keyoapi_example.py image-edit --run
# or
node node/keyoapi-example.mjs image-edit --run
Illustrative successful result
{
  "status": "succeeded",
  "data": [
    {
      "url": "https://example.invalid/result.png"
    }
  ]
}

OCR

Unlimited-OCR-2 · POST /v1/chat/completions

Set KEYO_IMAGE_URL to your accessible image URL. This model accepts image content through the documented multimodal message format.

Request parameters
{
  "model": "Unlimited-OCR-2",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Extract all text in the image"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "${KEYO_IMAGE_URL}"
          }
        }
      ]
    }
  ]
}
python python/keyoapi_example.py ocr --run
# or
node node/keyoapi-example.mjs ocr --run
Illustrative successful result
{
  "choices": [
    {
      "message": {
        "content": "Example text"
      }
    }
  ]
}

Errors, receipts and billing

Save the request and task IDs printed by the client. A create timeout has an unknown outcome: check the receipt and logs before submitting again. To continue a saved job, use the same scenario with --run --resume TASK_ID; this sends GET only.

{"error":{"message":"Invalid or missing parameter","type":"invalid_request_error"}}

400: fix parameters. 401/403: check your key, group and permissions. For a rate-based 429, respect Retry-After; balance or quota errors need a billing fix. Never turn failed POST requests into automatic replacement jobs.

Estimates use the selected model’s billing unit, group and specification. Token prices separate input and output; image requests may depend on size; video and audio can be billed by seconds, characters or requests; documents may use pages. Polling is not a second generation request. For refunds and any separate violation fee, read the billing help and your account records.

Billing & refunds · Service status

Read model metadata

GET /api/pricing is public and requires no key. data lists exact model_name, quota_type, billing_unit, supported_endpoint_types, enable_groups, has_price_tiers and contract_status; group_ratio is separate. Token base prices use model_ratio × 2 USD per 1M input tokens and completion_ratio for output. Fixed prices use model_price per billing_unit; unknown contracts and tiers must not be treated as zero. The public snapshot adds schema_version, retrieved_at and stale_after_seconds.

Live catalog JSON · Dated snapshot JSON

Connect existing developer tools

Start with the tool’s OpenAI-compatible configuration. Use https://www.keyoapi.xyz/v1, your own key and an exact model ID. Each tool and model still needs separate checks for streaming, tools and structured responses; these recipes are not official partnerships.

LiteLLM
import os
from litellm import completion
response = completion(
    model="openai/" + os.environ["KEYO_MODEL"],
    api_base="https://www.keyoapi.xyz/v1",
    api_key=os.environ["KEYO_API_KEY"],
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=64,
)
print(response.choices[0].message.content)
LiteLLM documentation
LangChain
import os
from langchain_openai import ChatOpenAI
model = ChatOpenAI(
    model=os.environ["KEYO_MODEL"],
    base_url="https://www.keyoapi.xyz/v1",
    api_key=os.environ["KEYO_API_KEY"],
    max_tokens=64,
    max_retries=0,
)
print(model.invoke("Hello").content)
LangChain documentation

Dify / Cherry Studio: choose the custom OpenAI-compatible connection and configure the same URL, key and model. Cline / OpenCode: additionally test tool calling and streaming before agent use. Menus and supported features vary by tool version. Run one short test deliberately; do not enable automatic retries for paid generation tasks.

Projects and evidence

Use these runnable examples as a starting point for a video generator, voice feature or document workflow. They are platform examples, not customer endorsements. Submit a reproducible issue with request IDs privately to support; never include keys or private input files.