OpenAI
The GPT models are the best in class LLMs and used as the default LLM by Assistants.
Authentication
Set your OPENAI_API_KEY
environment variable. You can get one from OpenAI here.
Example
Use OpenAIChat
with your Assistant
:
Params
For more information, please refer to the OpenAI docs as well.
OpenAI model ID.
If specified, openai system will make a best effort to sample
deterministically, such that repeated requests with the same seed
and
parameters should return the same result.
The maximum number of tokens to generate in the chat completion.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.
An object specifying the format that the model must output.
Setting to { "type": "json_object" }
enables JSON mode, which guarantees the message the model generates is valid JSON.
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.
Up to 4 sequences where the API will stop generating further tokens.
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100.
Headers added to the OpenAI request.
OpenAI API Key
OpenAI organization
OpenAI Base URL
Additional key word argumens used when creating the OpenAI()
client.
Provide your own OpenAI() client to use
Was this page helpful?