API Documentation
Easily integrate text, image, and video generation models through a unified OpenAI-compatible API.
Base URL & Authentication
All API requests require the unified Base URL and your API Key (Token) in the Authorization header.
Text Completions APIPOST /v1/chat/completions
Used for chatting, coding, translating, etc. with text models. Fully compatible with OpenAI's `/v1/chat/completions` standard.
cURL Example
bash
curl https://api.onekeymodel.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}'Python Example
python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.onekeymodel.com/v1"
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)Image Generations APIPOST /v1/images/generations
Used for generating images. Supports Midjourney, DALL-E 3, wan2.7-image, and more.
cURL Example
bash
curl https://api.onekeymodel.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-d '{
"model": "wan2.7-image",
"prompt": "A beautiful sunset over the mountains, digital art",
"n": 1,
"size": "1024x1024"
}'Python Example
python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.onekeymodel.com/v1"
)
response = client.images.generate(
model="wan2.7-image",
prompt="A beautiful sunset over the mountains, digital art",
n=1,
size="1024x1024"
)
print(response.data[0].url)Video Generations API
Since video generation takes longer (like wan2.7-t2v), the process is split into two steps: submitting the task and polling for the result.