Verified integration · OpenAI Python and Agents SDK

Use the OpenAI Responses API with a custom Base URL

Point the official Python client at Primordial AI, discover a current model ID, run a minimal Responses request, and keep unverified advanced features outside your production assumptions.

Verified 2026-08-24POST /v1/responsesPython SDK parsedNon-streaming baseline

Direct answer

Create the official OpenAI Python client with base_url="https://www.primoraihub.com/v1", then call client.responses.create(...). Keep the key in a server-side environment variable and use a model ID returned by your authenticated GET /v1/models request.

SDK Base URLhttps://www.primoraihub.com/v1
ResourcePOST https://www.primoraihub.com/v1/responses
Minimal inputmodel + input + optional max_output_tokens
Model sourceGET https://www.primoraihub.com/v1/models
AuthenticationBearer token from a server-side Primordial AI API key

The official OpenAI Python library documents client.responses.create. The endpoint behavior and verification evidence below describe Primordial AI; they are not an OpenAI endorsement of this service.

Python: discover first, then create a Response

pip install --upgrade openai

export PRIMORDIAL_API_KEY="YOUR_PRIMORDIAL_API_KEY"
export PRIMORDIAL_MODEL_ID="MODEL_ID_FROM_V1_MODELS"
import os
from openai import OpenAI

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

model_id = os.environ["PRIMORDIAL_MODEL_ID"]
available_ids = {item.id for item in client.models.list().data}
if model_id not in available_ids:
    raise RuntimeError(f"Model is not currently available: {model_id}")

response = client.responses.create(
    model=model_id,
    input="Reply with one short sentence.",
    max_output_tokens=64,
)

print(response.output_text)

Do not substitute a model name copied from another provider. Account access and model routing can differ; the live model list is the current availability check.

Separate HTTP routing from SDK parsing

When the SDK raises a parsing or transport error, reproduce the smallest request with cURL. This distinguishes authentication and route behavior from client-side parsing.

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

curl https://www.primoraihub.com/v1/responses \
  -H "Authorization: Bearer $PRIMORDIAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID_FROM_V1_MODELS",
    "input": "Reply with ok only.",
    "max_output_tokens": 16
  }'

OpenAI Agents SDK: install one custom client

The official Agents SDK configuration guide accepts a custom AsyncOpenAI client. The SDK uses the Responses path by default, while its model-provider guide warns that compatible providers can differ by API and feature.

import os
from openai import AsyncOpenAI
from agents import (
    Agent,
    Runner,
    set_default_openai_client,
    set_tracing_disabled,
)

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

set_default_openai_client(client, use_for_tracing=False)
set_tracing_disabled(True)

agent = Agent(
    name="Assistant",
    model=os.environ["PRIMORDIAL_MODEL_ID"],
)

result = await Runner.run(agent, "Reply with one short sentence.")
print(result.final_output)

This page did not independently verify an Agents SDK run. The example follows the official custom-client configuration, but tracing, tools, handoffs, sessions, and provider-specific semantics require separate tests.

What was actually verified

On August 24, 2026, a production test used the official OpenAI Python package, the custom /v1 Base URL, a currently configured model, a string input, and max_output_tokens=16. The client returned a parsed Response with a non-empty ID, object type response, and non-empty output_text.

Covered by that test

  • Bearer authentication with a valid Primordial AI key.
  • A minimal, non-streaming POST /v1/responses request.
  • Parsing by the official Python client into its Response type.

Not covered by that test

  • Streaming or the Responses WebSocket transport.
  • Built-in tools, custom function calls, structured outputs, images, or file inputs.
  • previous_response_id, conversation state, background mode, or response lifecycle methods.
  • Every model currently visible to every account.

A successful minimal request is not a blanket compatibility guarantee. Add one optional feature at a time and keep a regression request for the exact shape your application ships.

Troubleshooting sequence

  1. 401: verify the key with GET /v1/models and confirm it is not exposed, expired, disabled, or copied with whitespace.
  2. 404: confirm the Base URL includes /v1 and that the application is calling Responses rather than a provider-specific route.
  3. Model error: refresh the live model list and confirm the selected ID supports the Responses route.
  4. Parsing error: run the raw cURL request, save the HTTP status and request ID without secrets, and compare the minimal response shape.
  5. Advanced feature error: remove tools, streaming, state, and optional parameters; restore them individually after the baseline succeeds.

Use the API error troubleshooting guide for status-specific branches and safe logging guidance.

Frequently asked questions

What Base URL should the OpenAI client use?

Use https://www.primoraihub.com/v1. The client appends the /responses resource path.

How is Responses different from Chat Completions?

Responses uses an input-oriented request and a Response object. Chat Completions uses a messages array and choices. Keep the API shape your application already depends on unless you need a Responses-specific capability.

Can the OpenAI Agents SDK use this endpoint?

It accepts a custom AsyncOpenAI client. Configure that client for model calls, and disable or separately configure tracing so a provider key is not sent to OpenAI tracing.

Has this endpoint been tested with the Python SDK?

Yes, for one minimal non-streaming request on August 24, 2026. That test does not cover every model or optional Responses feature.

How should I select a model ID?

Call GET /v1/models with your key and use an ID currently returned for your account.