apimaxDocs
DocsPricingConsole
API ReferenceIntegration GuideUser GuideChangelog

Get started

Quick Start

FAQ

FAQ & Troubleshooting

Docs / Get started

Get startedQuick StartAPI KeyText GenerationImage GenerationAsync Tasks

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:

text
https://api.apimax.ai

Unless 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#

TypeHow to submitHow to get results
Text chatSynchronous HTTP requestText returned directly in the response
Image generationAsynchronous taskGET /v1/tasks/{id}
Video generationAsynchronous taskGET /v1/tasks/{id}
Music generationAsynchronous taskGET /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:

bash
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:

bash
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:

bash
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:

json
{
  "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:

bash
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:

json
{
  "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:

python
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 failed states 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.

Next steps

All docs
FAQ & TroubleshootingCommon questions about accounts, top-ups, API keys, model calls, asynchronous tasks, and result links.
On this page
OverviewQuick IntegrationPrerequisites1. Register and sign in2. Create an API key3. Choose the API base URLCalling patternsText generationImage generationQuerying tasksComplete Python exampleRecommendations before going liveNext steps