OpenAI client integration
Use the Python client with a company API base and dedicated credential.
Configure the client explicitly rather than changing a global machine-wide endpoint. The OpenAI-style base includes /v1. Choose Chat Completions or Responses according to the application and model, not just the package name.
python -m pip install openai
export B2B_API_KEY='mg_live_...'
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ['B2B_API_KEY'],
base_url='https://api.b2b-llm.com/v1')
result = client.responses.create(
model='gpt-5.4',
input='Write a concise status message for an internal ticket.'
)
print(result.output_text)
For a Chat-only model, use client.chat.completions.create with a messages list instead. Do not pass a Responses input array to that method. Replace the sample model with an enabled ID from your account's catalog.
On PowerShell, set $env:B2B_API_KEY = 'mg_live_...' in the process that launches the application. Avoid committing values into example files. Catch client exceptions while keeping the safe request ID, and make retry behavior explicit because a timed-out inference request may have been processed.
Library versions can change. Refer to the installed SDK's official documentation for available client methods; the endpoint and payload contract in this handbook remains the basis for your integration test.
Dedicated Images integration
Do not reuse these text snippets unchanged for company images. Persist a single intention identifier, send Idempotency-Key, preserve the actor/project key, and handle the dedicated Images 202/state/download flow. Client methods differ in their treatment of asynchronous envelopes and authenticated relative URLs; test against the documented HTTP contract, not a presumed SDK feature. Automatic paid POST retries should be disabled. Images operations describes safe lookup and download retry.