Created
November 18, 2024 15:14
-
-
Save dhruvilp/d29c647fbfde843def8a4bbd73259bda to your computer and use it in GitHub Desktop.
AIML API Code Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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