Nexevo.aiNexevo.ai
← All examples
Quick start

2-line switch: switching from OpenAI to Nexevo

Change two lines of configuration, keep the OpenAI SDK + code, and only change the endpoint.

python
# Before — using OpenAI directly
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "..."}],
)

# After — same code, two lines changed
from openai import OpenAI
client = OpenAI(
    api_key=os.environ["NEXEVO_API_KEY"], # 👈 our key
    base_url="https://api.nexevo.ai/v1", # 👈 our endpoint
)
response = client.chat.completions.create(
    model="deepseek-chat", # 👈 cheaper, often as good
    messages=[{"role": "user", "content": "..."}],
)
2-line switch: switching from OpenAI to Nexevo — Nexevo Cookbook | Nexevo.ai