from openai import OpenAI
client = OpenAI(
base_url="https://router.neutrinoapp.com/api/llm-router",
api_key="<Neutrino-API-key>"
)
response = client.chat.completions.create(
# Instead of a specific model, set this to the ID of your Neutrino Router
model="your-neutrino-router-id", # (or 'default')
messages = [
{"role": "system", "content": "You are a helpful AI assistant. Your job is to be helpful and respond to user requests."},
{"role": "user", "content": "Explain what artificial intelligence is"},
],
stream=True
)
for i, chunk in enumerate(response):
if i == 0:
print(f"Optimal model: {chunk.model}")
print(chunk.choices[0].delta.content, end="")