from openai import OpenAI
client = OpenAI(
api_key="your-open-router-api-key",
base_url="https://gateway.adaline.ai/v1/open-router/"
)
headers = {
"adaline-api-key": "your-adaline-api-key",
"adaline-project-id": "your-project-id",
"adaline-prompt-id": "your-prompt-id"
}
stream = client.chat.completions.create(
model="openai/gpt-4-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Compare different programming languages for AI development."}
],
stream=True,
extra_headers=headers
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")