Docs / Get started
Quick Start
Complete your first APIMAX integration: create an API key, make a synchronous text call, submit an asynchronous image task, and query tasks through the unified task API.
Quick Integration#
This guide walks you through your first APIMAX API call. Text models use synchronous endpoints, while generation tasks such as images, videos, and music typically use an asynchronous pattern: submit the task first, then query its status and results through the unified task API.
Prerequisites#
1. Register and sign in#
Sign in to APIMAX and open the user console. Before calling the API, make sure your account is in good standing, and top up your balance on the Wallet Top-up page as needed.
2. Create an API key#
Go to the API Keys page to create a key. Keys usually start with sk-; store the key in a secure location immediately after creation.
An API key represents your calling identity and billing authority. Never put it in browser front-end code, public repositories, chat logs, or client install packages.
3. Choose the API base URL#
All examples in this guide use the primary endpoint:
https://api.apimax.aiUnless your client explicitly requires it, do not manually append endpoint paths to the Base URL. If the primary endpoint suffers a network failure, you can temporarily use the backup endpoint published in the console to troubleshoot.
Calling patterns#
| Type | How to submit | How to get results |
|---|---|---|
| Text chat | Synchronous HTTP request | Text returned directly in the response |
| Image generation | Asynchronous task | GET /v1/tasks/{id} |
| Video generation | Asynchronous task | GET /v1/tasks/{id} |
| Music generation | Asynchronous task | GET /v1/tasks/{id} |
A successful asynchronous submission only means the task has been accepted, not that generation is complete. Clients must handle pending, processing, completed, and failed.
Text generation#
APIMAX is compatible with the OpenAI Chat Completions API. Replace the model name with a model ID from the console's model list that is available to your account:
curl --request POST \
--url https://api.apimax.ai/v1/chat/completions \
--header "Authorization: Bearer YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "YOUR_TEXT_MODEL",
"messages": [
{"role": "user", "content": "Reply with exactly: connection successful"}
]
}'On success, choices[0].message.content in the response is the model's reply. Some models stream by default; if your client cannot easily handle SSE, set stream=false explicitly in the request.
Claude models can also be called through the native Messages API:
curl --request POST \
--url https://api.apimax.ai/v1/messages \
--header "x-api-key: YOUR_API_KEY" \
--header "anthropic-version: 2023-06-01" \
--header "Content-Type: application/json" \
--data '{
"model": "YOUR_CLAUDE_MODEL",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Reply with exactly: connection successful"}
]
}'Image generation#
The asynchronous image endpoint is POST /v1/images/async-generations:
curl --request POST \
--url https://api.apimax.ai/v1/images/async-generations \
--header "Authorization: Bearer YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gpt-image-2",
"prompt": "Minimalist futuristic product poster on a white background, soft studio lighting",
"size": "1:1",
"quality": "high",
"n": 1
}'On success, a task object is returned immediately:
{
"id": "task_xxxxxxxxxxxxxxxxx",
"object": "image.generation.task",
"status": "pending",
"progress": 0,
"model": "gpt-image-2"
}The size, quality, reference-image, and other parameters a model supports are defined by that model's documentation. Do not copy parameters from other models.
Querying tasks#
Image, video, and music tasks are all queried through the same endpoint:
curl https://api.apimax.ai/v1/tasks/YOUR_TASK_ID \
--header "Authorization: Bearer YOUR_API_KEY"When a task completes, image tasks return the result URL in the data array:
{
"id": "task_xxxxxxxxxxxxxxxxx",
"status": "completed",
"progress": 100,
"data": [
{
"url": "https://example.com/result.png",
"url_expires_at": 1780000000
}
]
}The data structure differs across task types; parse it according to the documentation for the endpoint you called. Result URLs may expire, so in production you should download and re-store results promptly after a task completes.
Complete Python example#
The following example submits an image task and polls until it reaches a terminal state:
import os
import time
import requests
API_KEY = os.environ["APIMAX_API_KEY"]
BASE_URL = "https://api.apimax.ai"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
response = requests.post(
f"{BASE_URL}/v1/images/async-generations",
headers=HEADERS,
json={
"model": "gpt-image-2",
"prompt": "Minimalist product poster in blue glass",
"size": "1:1",
"quality": "high",
"n": 1,
},
timeout=30,
)
response.raise_for_status()
task_id = response.json()["id"]
deadline = time.time() + 300
while time.time() < deadline:
result = requests.get(
f"{BASE_URL}/v1/tasks/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=30,
)
result.raise_for_status()
task = result.json()
if task["status"] == "completed":
print(task["data"][0]["url"])
break
if task["status"] == "failed":
raise RuntimeError(task.get("error", "Task failed"))
time.sleep(3)
else:
raise TimeoutError("Task polling timed out")Recommendations before going live#
- Store keys in environment variables or a secrets management service.
- Use different keys for test and production environments, and set reasonable quota limits.
- Handle HTTP 429, 5xx, and asynchronous
failedstates separately. - Poll image tasks every 2 to 3 seconds; use a lower polling frequency for video tasks.
- Keep complete task IDs and error objects to make troubleshooting easier in usage logs or support tickets.
- Move generated results to your own object storage as soon as possible.

