How to integrate OpenAI with Lytix
Use Lytix to manage your evaluation and usage diretly with the OpenAI SDK. Gain access to models across providers and manage your usage and billing.
Prerequisite First create a lytix account here
Start by creating and noting down a lytix api key. See instructions here
With 2 lines you can start using Lytix to manage your evaluation and usage.
🇪🇺 Note You will need to use https://eu.api.lytix.co/proxy/v2/openai
if you are in the EU region.
Optimodel supports a variety of optional parameters to help you get the best results.
You will need to use the optimodel-py
/@lytix/client
package to use these parameters.
The following optional parameters are supported:
lytix-guards
: Pass in a list of fallback models to use
See here for a list of all supported guards
lytix-fallbackModels
: Pass in a list of extra models to try if the primary model fails. This can be helpful in mitigating provider outages.
lytix-speedPriority
: Pass in a speed priority to use
If set to low
, optimodel will choose the cheapest possible model across all providers (for example if you have two providers bedrock
and anthropic
that both offer claude-3-opus
, optimodel will choose the claude-3-opus
model with the lowest price regardless of which provider is faster). If set to high
, optimodel will choose the fastest possible model across all providers.
lytix-provider
: Pass in a provider to use
Explicitly specify a provider to use incase you have multiple providers available for a specific model and want to force a specific one.
You can also track workflows, users and sessions to get a better understanding of your users and how they interact with your models.
sessionId
: A unique identifier for the session.
userId
: A unique identifier for the user.
workflowName
: A unique identifier for the workflow. If this workflow does not exist, it will be created and can be viewed here
Passing images to any model uses the OpenAIs syntax. Underneath we’ll convert the syntax for the model you’re using.
Then you can switch to a model such as claude-3-5-sonnet
and pass the image in with no code changes.
Beyond the models available on the OpenAI API, Lytix also supports a range of other models from different providers. Just add the credentials for the model/provider and you can start using them immediately.
Then just update our model
field to the model you want to use.
To pass in credentials for a provider, you can add the credentials to the headers. The following is a list of credentils you can pass in:
mistralApiKey
: The API key for the Mistral API.mistralCodeStralApiKey
: The API key for the Mistral CodeStral API.openaiKey
: The API key for the OpenAI API.anthropicApiKey
: The API key for the Anthropic API.groqApiKey
: The API key for the Groq API.togetherApiKey
: The API key for the Together API.geminiApiKey
: The API key for the Gemini API.Bedrock To run models via bedrock, 3 headers are required:
awsAccessKeyId
: The access key for the AWS account.awsSecretKey
: The secret access key for the AWS account.awsRegion
: The session token for the AWS account.You can see the list of up to date models and providers here and clicking “Available Models”.
How to integrate OpenAI with Lytix
Use Lytix to manage your evaluation and usage diretly with the OpenAI SDK. Gain access to models across providers and manage your usage and billing.
Prerequisite First create a lytix account here
Start by creating and noting down a lytix api key. See instructions here
With 2 lines you can start using Lytix to manage your evaluation and usage.
🇪🇺 Note You will need to use https://eu.api.lytix.co/proxy/v2/openai
if you are in the EU region.
Optimodel supports a variety of optional parameters to help you get the best results.
You will need to use the optimodel-py
/@lytix/client
package to use these parameters.
The following optional parameters are supported:
lytix-guards
: Pass in a list of fallback models to use
See here for a list of all supported guards
lytix-fallbackModels
: Pass in a list of extra models to try if the primary model fails. This can be helpful in mitigating provider outages.
lytix-speedPriority
: Pass in a speed priority to use
If set to low
, optimodel will choose the cheapest possible model across all providers (for example if you have two providers bedrock
and anthropic
that both offer claude-3-opus
, optimodel will choose the claude-3-opus
model with the lowest price regardless of which provider is faster). If set to high
, optimodel will choose the fastest possible model across all providers.
lytix-provider
: Pass in a provider to use
Explicitly specify a provider to use incase you have multiple providers available for a specific model and want to force a specific one.
You can also track workflows, users and sessions to get a better understanding of your users and how they interact with your models.
sessionId
: A unique identifier for the session.
userId
: A unique identifier for the user.
workflowName
: A unique identifier for the workflow. If this workflow does not exist, it will be created and can be viewed here
Passing images to any model uses the OpenAIs syntax. Underneath we’ll convert the syntax for the model you’re using.
Then you can switch to a model such as claude-3-5-sonnet
and pass the image in with no code changes.
Beyond the models available on the OpenAI API, Lytix also supports a range of other models from different providers. Just add the credentials for the model/provider and you can start using them immediately.
Then just update our model
field to the model you want to use.
To pass in credentials for a provider, you can add the credentials to the headers. The following is a list of credentils you can pass in:
mistralApiKey
: The API key for the Mistral API.mistralCodeStralApiKey
: The API key for the Mistral CodeStral API.openaiKey
: The API key for the OpenAI API.anthropicApiKey
: The API key for the Anthropic API.groqApiKey
: The API key for the Groq API.togetherApiKey
: The API key for the Together API.geminiApiKey
: The API key for the Gemini API.Bedrock To run models via bedrock, 3 headers are required:
awsAccessKeyId
: The access key for the AWS account.awsSecretKey
: The secret access key for the AWS account.awsRegion
: The session token for the AWS account.You can see the list of up to date models and providers here and clicking “Available Models”.