Async
OpenAI
This page will show you how to log requests in Helicone when using OpenAI. This does not use the Helicone Proxy. For more information on Async Logging, see the Proxy vs Async page.
Python
Node.js
Raw
1 line integration
Add HELICONE_API_KEY
to your environment variables.
export HELICONE_API_KEY=sk-<your-api-key>
# You can also set it in your code (See below)
Replace
from openai import openai
with
from helicone.openai_async import openai
More complex example
from helicone.openai_async import openai, Meta
# export HELICONE_API_KEY=sk-<your-api-key>
# or ...
# from helicone.globals import helicone_global
# helicone_global.api_key = "sk-<your-api-key>"
x = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{
"role": "system",
"content": "This will be logged"
}],
max_tokens=512,
helicone_meta=Meta(
custom_properties={
"age": 25
}
)
)