Powerful AI Integration at Your Fingertips For Free
Made With ❤️ by Parth Sadaria
&stream=true
to enable streaming responses.
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello, AI!"
}
],
"stream": False #specify it
}
{{
"id": "chatcmpl-89DmxGJl4oqEultjlLBnGfdkV7Euk",
"model": "gpt-4o",
"object": "chat.completion",
"created": 1731674826,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 11,
"completion_tokens": 9,
"total_tokens": 20
}
}
}
import openai # hampe to he hi no :p (not needed) api_key = '' # Use the custom API endpoint openai.api_base = "https://parthsadaria-lokiai.hf.space" openai.api_key = api_key def chat_with_gpt(): try: response = openai.ChatCompletion.create( model="gpt-4o", messages=[{"role": "user", "content": "hi homie"}], stream=False ) print(response['choices'][0]['message']['content']) except Exception as e: print(f"Error: {e}") chat_with_gpt()
More info at https://parthsadaria-lokiai.hf.space/models
Contact me directly for Loki.AI integration! Report Bugs and issues 🐛