Docs
Integrate with the SDKs you already use.
Requests flow through Turiloop, with accounts, keys, and billing managed in one place.
Base URL
https://api.turing.yun/v1Authentication
Bearer followed by your API key
Chat
Integrate with common SDKs
Billing
Pre-hold, then settle on actual usage
Quickstart
After creating a key, point baseURL at Turiloop and keep the key server-side.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TURILOOP_API_KEY,
baseURL: "https://api.turing.yun/v1"
});
const completion = await client.chat.completions.create({
model: "deepseek-v4-pro",
messages: [{ role: "user", content: "Hello, Turiloop" }]
});The gateway also implements the Anthropic Messages API (/v1/messages): clients such as Claude Code and the Anthropic SDK work out of the box, and each request is routed to the model you set in the model field. The OpenAI-compatible chat endpoint remains fully available.
/v1/messages/v1/chat/completionsThe model is fixed to gpt-image-2 and is compatible with the OpenAI image API: use /images/generations for text-to-image and /images/edits to edit from a base image.
https://api.turing.yun/v1/images/generationshttps://api.turing.yun/v1/images/editsimport OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TURILOOP_API_KEY,
baseURL: "https://api.turing.yun/v1"
});
const image = await client.images.generate({
model: "gpt-image-2",
prompt: "A premium, high-tech product poster",
size: "3840x2160",
quality: "high",
n: 1
});You can also upload the file directly with curl (multipart):
curl https://api.turing.yun/v1/images/edits \ -H "Authorization: Bearer $TURILOOP_API_KEY" \ -F "model=gpt-image-2" \ -F "image=@input.png" \ -F "prompt=Replace the background with a neon street at night" \ -F "size=3840x2160"
Common params: prompt description (required) · size up to 3840x2160 · quality low / medium / high · n number of images (currently 1) · response_format url or b64_json · for edits, image is the base image (required). A client timeout of ≥ 300s is recommended.
Base URL
All requests go to a single Turiloop API endpoint, where the gateway validates, forwards, and logs each call.
https://api.turiloop.com/v1Authentication
Authenticate with a Bearer key. Keep the key server-side only.
Authorization: Bearer YOUR_TURILOOP_API_KEYStreaming
Keep using the stream parameter and read incremental content over SSE.
stream: trueBilling
Balance is prepaid; overdrafts are not allowed. Large requests are held first, then settled on actual usage.
Pre-hold → Settle on usage → Refund differenceError Codes
Common errors include insufficient balance, model unavailable, rate limiting, and service timeouts. Handle them by HTTP status code and the code field.
SDK Examples
Node.js, Python, and curl all use the same base URL and key. Keep the key in server-side environment variables only.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TURILOOP_API_KEY"],
base_url="https://api.turing.yun/v1"
)
chat = client.chat.completions.create(
model="deepseek-v4-pro",
messages=[{"role": "user", "content": "Hello"}]
)
print(chat.choices[0].message.content)curl https://api.turing.yun/v1/chat/completions \
-H "Authorization: Bearer $TURILOOP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{"role": "user", "content": "Hello"}
]
}'Video generation (HappyHorse)
The HappyHorse family supports text-to-video (t2v), image-to-video (i2v), reference-to-video (r2v) and video-edit. Billing is per second of output at two resolution tiers (720P / 1080P — see Pricing). Video runs as an async task: create a task to get a task_id, then poll for the result.
curl -X POST "https://api.turiloop.com/v1/video/generations" \n -H "Authorization: Bearer $TURILOOP_API_KEY" \n -H "Content-Type: application/json" \n -d {
"model": "happyhorse-1.1-t2v",
"prompt": "A corgi surfing on a sunny beach, cinematic",
"size": "1280*720",
"seconds": "3"
}curl "https://api.turiloop.com/v1/videos/{task_id}" \n -H "Authorization: Bearer $TURILOOP_API_KEY"
# status: queued -> in_progress -> completed
# On completed, metadata.url holds the generated MP4 (time-limited link, download promptly)Billing: seconds × the per-second rate of the chosen resolution, settled when the task is created; failed tasks are refunded in full automatically. Request fields: pass size as the pixel resolution "1280*720" (720P) or "1920*1080" (1080P); seconds is a string, 3-15. Models: happyhorse-1.1-t2v for text-to-video (prompt only); happyhorse-1.1-i2v for image-to-video (add image with a first-frame URL); happyhorse-1.1-r2v for reference-to-video (add images, an array of 1-9 reference URLs); happyhorse-1.0-video-edit for video editing. Task statuses: queued / in_progress / completed / failed.