OpenAI Python quickstart
Make a hosted OpenPond model request with the OpenAI Python SDK.
OpenAI Python quickstart
Install the OpenAI Python package in server-side code:
bash
pip install openaipython
import os
from openai import OpenAI
api_key = os.environ["OPENPOND_API_KEY"]
client = OpenAI(
api_key=api_key,
base_url="https://api.openpond.ai/opchat/v1",
)
models = client.models.list()
model = models.data[0].id
completion = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "Write one sentence about clean APIs."}],
)
print(completion.choices[0].message.content)Keep OPENPOND_API_KEY in server-side environment management, not a notebook
output, client application, or repository.
Next: Streaming.