OpenAI SDK
Configure the OpenAI SDK with your EasyAPI API key and base URL to access every supported model through the relay.
Prerequisites
- OpenAI SDK installed (Python: pip install openai; Node.js: npm install openai)
- An EasyAPI API token created in the console
Step 1: Get Your EasyAPI Token
Sign in to the EasyAPI console → Token Management and copy the API Key starting with sk-.
The token must have permission to call the target model.
Step 2: Configure Base URL and API Key
When initializing the OpenAI client, set api_key to your EasyAPI token and base_url to the site API address (must include the /v1 suffix).
https://token.easyapi.com/v1Create your token in Console → Token Management; see Standard Integration for the standard integration guide.
example.py
from openai import OpenAI
client = OpenAI(
api_key="sk-your-easyapi-token",
base_url="https://token.easyapi.com/v1",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)Step 3: Send a Chat Request
Call client.chat.completions.create and pass an EasyAPI-supported model ID (e.g. gpt-4o, deepseek-chat) as the model parameter.
Model IDs are listed in the model plaza; if you get a 404, confirm the model name matches the backend configuration.
Verification
- Running the sample code prints a model reply
- A matching call appears in EasyAPI console usage records