⌘

API Documentation

Quick start guide with code examples

Getting Started

Our REST API provides programmatic access to manage and retrieve data. All requests require authentication using an API key passed in the Authorization header.

Base URL

https://apiflowx.top

Authentication

Bearer Token

Response Format

JSON

All Endpoints

Click on an endpoint to view its code examples

Code Examples

Select an endpoint and programming language

POSTLLM Auto Route

POST /v1/llm/auto

Automatically select and use the best LLM model for your task

Node.js Example

import fetch from "node-fetch";

const res = await fetch("https://apiflowx.top/v1/llm/auto", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    messages: [{ role: "user", content: "写一δΈͺ产品介绍" }],
    strategy: { mode: "auto" },
    stream: false
  })
});

const data = await res.json();
console.log(data.response);

πŸ’‘ Quick Tips

  • β€’ Set strategy.mode to auto for best model selection
  • β€’ Pass stream: false for standard JSON response
  • β€’ Keep payload minimal for easier debugging

Response Examples

Example responses for the selected endpoint

200 OK

Successful response

JSON Response

{
  "success": true,
  "model": "gpt-4.1-mini",
  "response": "θΏ™ζ˜―δΈΊδ½ η”Ÿζˆηš„εΉΏε‘Šζ–‡ζ‘ˆ...",
  "usage": {
    "prompt_tokens": 398,
    "completion_tokens": 124,
    "total_tokens": 522
  },
  "provider": "openai",
  "request_id": "req_9f1a2e8"
}
4xx/5xx Error

Error response example

JSON Error

{
  "success": false,
  "error": {
    "code": "MODEL_UNAVAILABLE",
    "message": "No provider matched your route policy or constraints"
  }
}

⚠️ Common Error Scenarios

  • 400:Missing required message content
  • 401:Invalid API key in Authorization header
  • 402:Insufficient token balance for this request
  • 429:Rate limit exceeded for your current plan
  • 502:All candidate model providers failed

HTTP Status Codes Reference

200

OK

Request successful

400

Bad Request

Invalid request parameters

401

Unauthorized

Authentication required or failed

402

Payment Required

Insufficient token balance

429

Too Many Requests

Rate limit exceeded

500

Internal Server Error

Unexpected server error

502

Bad Gateway

Upstream model provider failed