Skip to content

Instantly share code, notes, and snippets.

@dhruvilp
Created November 18, 2024 15:14
Show Gist options
  • Save dhruvilp/d29c647fbfde843def8a4bbd73259bda to your computer and use it in GitHub Desktop.
Save dhruvilp/d29c647fbfde843def8a4bbd73259bda to your computer and use it in GitHub Desktop.
AIML API Code Snippet
# pip install openai
import os
from openai import OpenAI
aiml_api_key ='<YOUR_AIML_API_KEY>'
client = OpenAI(
api_key=aiml_api_key,
base_url="https://api.aimlapi.com",
)
response = client.chat.completions.create(
model="o1-mini",
messages=[
{
"role": "user",
"content": "Tell me, why is the sky blue?"
},
],
max_tokens=1000,
)
message = response.choices[0].message.content
print(f"Assistant: {message}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment