Libraries
Python library
We provide a Python library, which you can install as follows:
$ pip install openai
Once installed, you can use the bindings and your secret key to run the following:
import os
import openai
# Load your API key from an environment variable or secret management service
openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Completion.create(model="text-davinci-003", prompt="Say this is a test", temperature=0, max_tokens=7)
The bindings also will install a command-line utility you can use as follows:
$ openai api completions.create -m text-davinci-003 -p "Say this is a test" -t 0 -M 7 --stream
Node.js library
We also have a Node.js library, which you can install by running the following command in your Node.js project directory:
$ npm install openai
Once installed, you can use the library and your secret key to run the following:
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: "Say this is a test",
temperature: 0,
max_tokens: 7,
});
Community libraries
The libraries below are built and maintained by the broader developer community. If you'd like to add a new library here, please follow the instructions in our help center article on adding community libraries.
Please note that OpenAI does not verify the correctness or security of these projects.
C# / .NET
Crystal
Go
Java
Kotlin
Node.js
- openai-api by Njerschow
- openai-api-node by erlapso
- gpt-x by ceifa
- gpt3 by poteat
- gpts by thencc
- @dalenguyen/openai by dalenguyen
- tectalic/openai by tectalic