Skip to main content

OpenAI Libraries

Python library

We provide a Python library, which you can install by running:

pip install openai

Once installed, you can use the library and your secret key to run the following:

from openai import OpenAI

client = OpenAI(
api_key = '$ROCKAPI_API_KEY',
base_url = 'https://api.rockapi.ru/openai/v1'
)

chat_completion = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello world"}]
)

The bindings also will install a command-line utility you can use as follows:

$ openai -b 'https://api.rockapi.ru/openai/v1' -k '$ROCKAPI_API_KEY' api chat_completions.create -m gpt-4o-mini -g user "Hello world"

TypeScript / JavaScript library

We provide a TypeScript / JavaScript library with support for Node.js and various other runtimes. Install it by running:

npm install --save openai
# or
yarn add openai

Once installed, you can use the library and your secret key to run the following:

import OpenAI from "openai";

const openai = new OpenAI({
baseURL: 'https://api.rockapi.ru/openai/v1',
apiKey: '$ROCKAPI_API_KEY',
});

const chatCompletion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Say this is a test" }],
model: "gpt-4o-mini",
});

Azure OpenAI libraries

Microsoft's Azure team maintains libraries that are compatible with both the OpenAI API and Azure OpenAI services. Read the library documentation below to learn how you can use them with the OpenAI API.


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. You can also watch our OpenAPI specification repository on GitHub to get timely updates on when we make changes to our API.

Please note that OpenAI does not verify the correctness or security of these projects. Use them at your own risk!

C# / .NET

C++

Clojure

Crystal

Dart/Flutter

Delphi

Elixir

Go

Java

Julia

Kotlin

Node.js

PHP

Python

R

Ruby

Rust

Scala

Swift

Unity

Unreal Engine