Skip to main content
Version: 0.14

openai

Installation

pip install greptimeai

Setup

Before get started, export the following to your environment variables:

export GREPTIMEAI_HOST='<host>'
export GREPTIMEAI_DATABASE='<dbname>'
export GREPTIMEAI_TOKEN='<username>:<password>'

How-To

export OPENAI_API_KEY='sk-xxx'
from greptimeai import openai_patcher
from openai import OpenAI

client = OpenAI()
openai_patcher.setup(client=client) # This is the only line you need to add

chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
user="user_123",
)

You can find more details in example and cookbook