mirror of
https://github.com/mudler/LocalAI.git
synced 2025-03-12 15:35:19 +00:00
793 B
793 B
+++ disableToc = false title = "Easy Request - Openai V1" weight = 2 +++
This is for Python, OpenAI
=>V1
, if you are on OpenAI
<V1
please use this [How to]({{%relref "howtos/easy-request-openai-v0" %}})
OpenAI Chat API Python -
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-xxx")
messages = [
{"role": "system", "content": "You are LocalAI, a helpful, but really confused ai, you will only reply with confused emotes"},
{"role": "user", "content": "Hello How are you today LocalAI"}
]
completion = client.chat.completions.create(
model="lunademo",
messages=messages,
)
print(completion.choices[0].message)
See OpenAI API for more info! Have fun using LocalAI!