Developer guide · OpenAI-compatible API

Connect an existing OpenAI SDK to one production gateway.

Use a compatible base URL, fetch the live model list, and keep the request shape familiar while you evaluate Primordial AI for your application.

OpenAI-compatibleBearer authenticationLive model discovery

Quick answer

Set your client base URL to https://www.primoraihub.com/v1, send Authorization: Bearer YOUR_API_KEY, and call GET /v1/models before selecting a model ID.

Base URLhttps://www.primoraihub.com/v1
AuthenticationAuthorization: Bearer YOUR_API_KEY
Model discoveryGET https://www.primoraihub.com/v1/models
Chat endpointPOST https://www.primoraihub.com/v1/chat/completions

Which endpoint should you use?

  • Use /v1/chat/completions for the familiar messages-based chat format.
  • Use /v1/responses when your application is built around the Responses-style input format; follow the verified Python and Agents SDK guide.
  • Use /v1/messages when your integration already follows the Claude Messages request format.
  • Use /v1/images/generations for documented image-generation requests.

Endpoint parameters and current model availability can change. The API documentation and live /v1/models response are the source of truth. Use the focused model discovery and caching guide for production checks.

Try it with cURL

curl https://www.primoraihub.com/v1/models \
  -H "Authorization: Bearer $PRIMORDIAL_API_KEY"

curl https://www.primoraihub.com/v1/chat/completions \
  -H "Authorization: Bearer $PRIMORDIAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID_FROM_V1_MODELS",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Use the OpenAI Python SDK

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["PRIMORDIAL_API_KEY"],
    base_url="https://www.primoraihub.com/v1",
)

configured_id = os.environ["PRIMORDIAL_MODEL_ID"]
models = client.models.list()
available_ids = {model.id for model in models.data}
if configured_id not in available_ids:
    raise RuntimeError(f"Configured model is unavailable: {configured_id}")

response = client.chat.completions.create(
    model=configured_id,
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

For the exact Python base_url and JavaScript baseURL constructor options, use the focused custom base URL migration guide.

Production checklist

  • Fetch and cache the current model list rather than hard-coding an unverified model name.
  • Keep API keys in a server-side secret store; do not expose them in browser code or public repositories.
  • Log request IDs, latency, status codes, and token usage without logging secret values.
  • Confirm the endpoint, model, streaming behavior, and image parameters in the current documentation before release.

Already registered? Create or manage an API key, then use the key safety and authentication checklist. For Responses-style applications, use the Responses API custom Base URL guide; for a browser chat client, follow the Open WebUI setup guide; for a server-managed custom endpoint, use the LibreChat YAML guide; for workflow automation, use the n8n HTTP Request guide. Otherwise, read the complete API documentation or create an account.

Frequently asked questions

What base URL should an OpenAI-compatible client use?

Use https://www.primoraihub.com/v1 and authenticate with a Primordial AI API key.

How do I find the current model ID?

Call GET /v1/models and choose an ID returned by the live endpoint.

Can an existing OpenAI SDK use the gateway?

Point its base URL at the Primordial AI /v1 endpoint, then verify current support in the API documentation before production use.