If you are utilizing an OpenAI compatible endpoint, you can conveniently log
your requests to Helicone by modifying the base URL from
https://oai.helicone.ai/v1 to any of the following supported dedicated
endpoints:
- https://together.helicone.ai/v1
Are you using another target that is OpenAI compatible?If the target is a domain that has been approved with a dedicated domain (e.g., TogetherAI), then you can replace the base URL with the dedicated domain.
If the target has not been approved, you can utilize the Helicone Gateway to log your requests to Helicone.Example:Instead of using the base URLbase_url=“https://oai.helicone.ai/v1”, You can use the base URLbase_url=“https://together.helicone.ai/v1”,
OpenAI v1+
Set HELICONE_API_KEY as an environment variable
Copy
Ask AI
export HELICONE_API_KEY=<your API key>
Initialize the OpenAI client. This can also be done via a global client.
Copy
Ask AI
client = OpenAI( api_key="your-api-key-here", # Replace with your OpenAI API key base_url="https://oai.helicone.ai/v1", # Set the API endpoint default_headers= { # Optionally set default headers or set per request (see below) "Helicone-Auth": f"Bearer {HELICONE_API_KEY}", })
Send a request and attach extra headers
Copy
Ask AI
chat_completion = client.chat.completions.create( model="gpt-4-vision-preview", messages=[ {"role": "user", "content": "Hello world!"} ], extra_headers={ # Can also attach headers per request "Helicone-Auth": f"Bearer {HELICONE_API_KEY}", },)
Congratulations! Your OpenAI requests are now logging results to Helicone.
OpenAI <v1
Set HELICONE_API_KEY as an environment variable
Copy
Ask AI
export HELICONE_API_KEY=<your API key>
Modify the API base and add a Helicone-Auth header