Integrations
Markdown ↗

OpenAI SDKs

Python and server-side JavaScript official clients.

Manual setup

1. Keep the project package manager, SDK version and lockfile. If missing, install openai only with authorization: pip install openai in the active Python environment or npm install openai in the Node project.

2. Provide ZRELAY_API_KEY to the process using local hidden input or server secrets. These examples do not automatically load .env. Use a GPT Flex/Prime key for gpt-6.1-sol Responses. Save the Python example as example.py or JavaScript as example.mjs; executing either makes a billed request.

3. The SDK adds /responses to https://api.zrelay.net/v1. output_text is an SDK convenience, not a promised raw HTTP field. JavaScript explicitly checks the key to avoid falling back to OPENAI_API_KEY.

4. For a separate Gemini Prime Chat Completions route, use the shown chat.completions examples with gemini-3.7-flash and the matching key/client. Select endpoints by route rather than changing only model names. For Anthropic Python use Anthropic(base_url="https://api.zrelay.net", api_key=os.environ["ZRELAY_API_KEY"]); that SDK appends /v1/messages.

Configuration and commands

python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.zrelay.net/v1",
    api_key=os.environ["ZRELAY_API_KEY"],
)
response = client.responses.create(
    model="gpt-6.1-sol",
    input="Say hello in one sentence.",
    max_output_tokens=256,
)
print(response.output_text)
javascript
import OpenAI from "openai";

const apiKey = process.env.ZRELAY_API_KEY;
if (!apiKey) throw new Error("Set ZRELAY_API_KEY locally");
const client = new OpenAI({
  baseURL: "https://api.zrelay.net/v1",
  apiKey,
});
const response = await client.responses.create({
  model: "gpt-6.1-sol",
  input: "Say hello in one sentence.",
  max_output_tokens: 256,
});
console.log(response.output_text);
python
response = client.chat.completions.create(
    model="gemini-3.7-flash",
    messages=[{"role": "user", "content": "Hello"}], max_tokens=256,
)
print(response.choices[0].message.content)
javascript
const response = await client.chat.completions.create({
  model: "gemini-3.7-flash",
  messages: [{ role: "user", content: "Hello" }], max_tokens: 256,
});
console.log(response.choices[0].message.content);

Alternative: ask an AI assistant

Copy this complete prompt into your coding assistant. It describes configuration work; installation and paid tests need your authorization.

Setup prompt
Integrate Zrelay into this existing Python or server-side JavaScript project. Detect OS, runtime, package manager, installed OpenAI SDK version and existing call sites. Consult https://github.com/openai/openai-python or https://github.com/openai/openai-node and https://keys.zrelay.net/api/catalog. Preserve dependencies, lockfiles, SDK version and unrelated configuration; ask before installation or upgrades. Configure a dedicated client with https://api.zrelay.net/v1 and runtime ZRELAY_API_KEY; fail clearly when missing. Never read, print, commit or request my real key in chat; instruct me to enter it locally. For an enabled GPT Responses route use responses.create, gpt-6.1-sol, max_output_tokens 256 and the SDK output_text helper. For a Chat route use chat.completions.create and the exact enabled model/provider/pool. Respect the catalog output ceiling. Make minimal changes consistent with this project. Validate configuration and syntax offline without inference. Request explicit consent before any paid request. Do not claim streaming, tool-loop or hosted-tool compatibility from a text response. Report changed files, checks and remaining limitations.

Limits and verification

The enforced output ceiling is 4096; a budget of 256 can truncate output. Official SDKs retry some failures twice: consider max_retries=0 / maxRetries:0 for an authorized first smoke test. Do not add blind retries or infer hosted tools, streaming or complete tool-loop support from text output.

These recipes were reviewed against documentation and public catalog data. No client installation, authenticated request, paid inference, streaming or tool loop was executed. Validate configuration first; a later short text test does not establish complete agent compatibility.

Recheck the live catalog and your key’s provider/pool. The reviewed examples have 128000 input and 4096 output maxima unless a client limitation above prevents controlling the request. Never print, log or commit credentials.

Official sources

Documentation checked 2026-11-09; mutable sources can differ from your installed version.

https://developers.openai.com/api/docs/libraries

https://keys.zrelay.net/api/catalog

https://github.com/openai/openai-python/blob/main/src/openai/types/responses/response.py

https://github.com/openai/openai-node/blob/main/src/client.ts

https://github.com/openai/openai-python

https://github.com/openai/openai-node

https://keys.zrelay.net/api/catalog

Questions about your integration? support@zrelay.net