Skip to main content
Configure the OpenAI SDK with the APIONE base URL, API Key, and model ID. These examples run on your server.

Before you run the examples

Set APIONE_API_KEY and APIONE_MODEL using the quickstart. Copy the model ID from the available model list. Missing variables stop the examples instead of falling back to a fixed model. Do not put the full /chat/completions endpoint in the SDK base URL. The SDK appends the endpoint path.

Python

Install the dependency:
Save as app.py:
Run python app.py. Successful text output is in choices[0].message.content; usage helps track tokens. Check the console for final charges.

Node.js

Install the dependency:
Save as app.mjs:
Run node app.mjs. Use a Node.js version supported by the SDK and pin dependencies in your project.

Set environment variables and run

Set your key and an actual model ID in the same terminal, then run the saved file:

Timeouts, retries, and troubleshooting

The examples set a 60-second SDK timeout and disable SDK retries to make a single request easier to inspect. These are example settings, not platform time limits. Set them for your workload and check SDK defaults so retries do not multiply application retries. Record status codes, request IDs, and timing, and redact sensitive fields. On failure, verify the base URL, key, and model ID before troubleshooting. For incremental output, see streaming. Reference: APIONE OpenAI SDK documentation.