Skip to content

Repository files navigation

APIMart API Examples

Production-ready examples for the APIMart OpenAI-compatible AI API gateway — chat, images, videos, audio, and account utilities through one unified API.

Website API Docs OpenAI Compatible Postman Collection

APIMart provides a unified gateway for 500+ AI models — chat models such as GPT, Claude and Gemini; image models such as GPT-Image-2, Imagen and Nano Banana; video models such as Sora, Veo and Kling; plus audio models — with a familiar OpenAI-style API surface.

Quick start

export APIMART_API_KEY="sk-your-key"
export APIMART_BASE_URL="https://api.apimart.ai/v1"

cURL

curl --request POST \
  --url "$APIMART_BASE_URL/chat/completions" \
  --header "Authorization: Bearer $APIMART_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful AI assistant."},
      {"role": "user", "content": "Explain APIMart in one sentence."}
    ]
  }'

Python

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python examples/python/chat_completions.py

JavaScript / Node.js

node examples/javascript/chat-completions.mjs

Examples included

Area Endpoint Example files Docs
Chat completions POST /v1/chat/completions examples/curl/chat-completions.sh, examples/python/chat_completions.py, examples/javascript/chat-completions.mjs General Chat API
Image generation POST /v1/images/generations examples/curl/gpt-image-2.sh, examples/python/gpt_image_2.py, examples/javascript/gpt-image-2.mjs GPT-Image-2 API
Video generation POST /v1/videos/generations examples/curl/sora-2-video.sh, examples/python/sora_2_video.py, examples/javascript/sora-2-video.mjs Sora 2 API
Async task polling GET /v1/tasks/{task_id} examples/curl/task-status.sh, examples/python/poll_task.py, examples/javascript/task-status.mjs Task Status
API key balance GET /v1/balance examples/curl/balance.sh, examples/python/balance.py Token Balance
Postman Collection v2.1 postman/APIMart.postman_collection.json Import into Postman

OpenAI SDK compatibility

Most text models can be called with the OpenAI SDK by changing the base URL and API key:

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["APIMART_API_KEY"],
    base_url="https://api.apimart.ai/v1",
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Write a haiku about APIs."}],
)
print(response.choices[0].message.content)

For async media models, submit a generation task first and then poll GET /v1/tasks/{task_id}?language=en until it completes.

Common environment variables

Variable Default Description
APIMART_API_KEY required Bearer token from https://apimart.ai/keys.
APIMART_BASE_URL https://api.apimart.ai/v1 API base URL.
APIMART_MODEL gpt-4o Chat model used by chat examples.
APIMART_TASK_ID none Task ID used by polling examples.

Useful APIMart links

Safety notes

  • Do not commit real API keys. Use .env locally and .env.example as a template.
  • Generated image and video URLs may expire; download assets you need to keep.
  • Media generation endpoints are asynchronous. Store the returned task_id and poll the task endpoint.

License

MIT — see LICENSE.

About

OpenAI-compatible APIMart API examples for chat, image, video, async tasks, balance, and Postman.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages