create ( model = "gpt-3.5-turbo", messages = ) # print the completion print ( chat_completion. Chat completionsĬhat models such as gpt-3.5-turbo and gpt-4 can be called using the chat completions endpoint. This param takes a Union] and will raise an error if the request exceeds that time in seconds (See: ). Most endpoints support a request_timeout param. recommendations, visualization of embeddings, and more. It contains code examples for: classification using fine-tuning, clustering, code search, customizing embeddings, question answering from a corpus of documents. api_key = "sk-."Įxamples of how to use this library to accomplish various tasks can be found in the OpenAI Cookbook. Or set openai.api_key to its value: openai. Either set it as the OPENAI_API_KEY environment variable before using the library: export OPENAI_API_KEY = 'sk-.' The library needs to be configured with your account's secret key which is available on the website. If you encounter a MissingDependencyError, install them with: pip install openai Usage They’re needed for some functionality of this library, but generally not for talking to the API. Install support for Weights & Biases: pip install openai ĭata libraries like numpy and pandas are not installed by default due to their size. Install dependencies for openai.embeddings_utils: pip install openai To install this package from source to make modifications to it, run the following command from the root of the repository: python setup.py install Want to use the package, run: pip install -upgrade openaiĪfter you have installed the package, import it at the top of a file: import openai To start, ensure you have Python 3.7.1 or newer. You can find usage examples for the OpenAI Python library in our API reference and the OpenAI Cookbook. With a wide range of versions of the OpenAI API. Themselves dynamically from API responses which makes it compatible Pre-defined set of classes for API resources that initialize The OpenAI Python library provides convenient access to the OpenAI APIįrom applications written in the Python language.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |