Make Your First Request
This guide uses Python 3.10 or later to call Chat Completions. Prepare a valid API Key, an available balance, and the complete model ID of a model that supports this API.
1. Set up Python
If Python is not installed, download it from the official Python website, then open a new terminal. Run the commands for your operating system below.
macOS / Linux:
python3 --version
mkdir -p certaedge-test
cd certaedge-test
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade openaiWindows PowerShell:
py -3 --version
mkdir certaedge-test
cd certaedge-test
py -3 -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade openaiLater commands use the virtual environment's Python executable directly, so you do not need to run an activation script. If the directory already exists, enter it without creating it again.
2. Set your key and model
Replace sk-YOUR_API_KEY with the complete key you copied. Replace YOUR_MODEL_ID with a real ID from the model catalog. Do not send the placeholder values.
macOS / Linux:
export CERTAEDGE_API_KEY='sk-YOUR_API_KEY'
export CERTAEDGE_MODEL='YOUR_MODEL_ID'Windows PowerShell:
$env:CERTAEDGE_API_KEY = 'sk-YOUR_API_KEY'
$env:CERTAEDGE_MODEL = 'YOUR_MODEL_ID'These variables apply only to the current terminal and programs launched from it. Set them again when you open a new terminal.
3. Save and run the test program
Create first_request.py in the certaedge-test directory, and save the following code with a text editor. On Windows, make sure the file is not named first_request.py.txt.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["CERTAEDGE_API_KEY"],
base_url="https://certaedge.com/v1",
timeout=60.0,
max_retries=0,
)
response = client.chat.completions.create(
model=os.environ["CERTAEDGE_MODEL"],
messages=[{"role": "user", "content": "Introduce yourself in one sentence."}],
stream=False,
)
print(response.choices[0].message.content)Run it in the same terminal where you set the environment variables.
macOS / Linux:
.venv/bin/python first_request.pyWindows PowerShell:
.\.venv\Scripts\python.exe first_request.py4. Confirm success
The terminal should print a model reply, and the request should appear in Usage Logs. Check the model, status, and usage before configuring your tools. This model request is billed at the selected model's rates.
Troubleshooting
| Symptom | What to do |
|---|---|
python3 or py not found | Install Python, open a new terminal, and check the version again. |
No module named openai | Make sure you install and run with the same virtual environment's Python executable shown above. |
KeyError: CERTAEDGE_API_KEY or CERTAEDGE_MODEL | Repeat step 2 in the current terminal. |
| 401 / model not found | Check the key and model ID, then see Troubleshooting. |
| TLS, connection, or timeout error | Check the service address and network first. A failure before any HTTP response is not a model-name error. |
If your model only supports Responses, Messages, or another protocol, this Chat Completions example does not apply. Choose a tool or request format that matches the supported protocol.