OpenAI compatibility

Prev Next

Available in Classic and VPC

The CLOVA Studio service provides compatibility with OpenAI API for major APIs, including Chat Completions and Embedding.

Compatible APIs

The list of APIs compatible with OpenAI API in CLOVA Studio is as follows:

API Method URI
Chat Completions, Chat Completions v3 POST /chat/completions
Embedding, Embedding v2 POST /embeddings
Get model. GET /models

Usage method

The following describes the request format and response format of the OpenAI-compatible APIs.

Request

By adjusting some of the request items in the CLOVA Studio API, you can use the OpenAI official library (SDK) and REST API.

API key

Use the test or service API key issued by the CLOVA Studio service.

Caution

The OpenAI-compatible APIs can only be used with a test API key or service API key issued from [API key] in CLOVA Studio.

API URL

The request API URL is as follows:

https://clovastudio.stream.ntruss.com/v1/openai/

Model

Enter the model name provided by the CLOVA Studio service as the model name in the request body.

Naming rule

The naming rule for request fields follows snake_case notation.

Response

It supports response results with the same structure and format as the OpenAI API.

SDK examples

The following is an example of using the CLOVA Studio service by utilizing the official OpenAI library.

Python

The example written in Python is as follows:

from openai import OpenAI

client = OpenAI(
    api_key="CLOVA_STUDIO_API_KEY",  # CLOVA Studio API key
    base_url="https://clovastudio.stream.ntruss.com/v1/openai"  # CLOVA Studio OpenAI-compatible API URL 
)

# Chat Completions
response = client.chat.completions.create(
    model="HCX-005",  # CLOVA Studio supported model name
    messages=[
        {"role": "system", "content": "You're a skilled AI assistant."},
        {"role": "user", "content": "Please explain artificial intelligence."}
    ]
)

print(response.choices[0].message.content)

# Embeddings
embedding = client.embeddings.create(
    model="bge-m3", # CLOVA Studio supported model name (embedding)
    input="Thank you for using CLOVA Studio.",
    encoding_format="float" # Must be set when using embedding with the OpenAI Python SDK (Base64 not supported).
    )
Caution

If you want to use embedding with the official OpenAI Python library, encoding_format="float" is a required setting.

TypeScript/JavaScript (Node.js)

The example written in TypeScript/JavaScript (Node.js) is as follows:

import OpenAI from "openai";

const openai = new OpenAI({
    baseURL: "https://clovastudio.stream.ntruss.com/v1/openai", // CLOVA Studio OpenAI-compatible API URL
    apiKey: "YOUR_API_KEY",
    }); // CLOVA Studio API key

// Chat Completions
const completion = await openai.chat.completions.create({
    model: "HCX-005",   // CLOVA Studio supported model name
    messages: [
        {"role": "system", "content": "You're a skilled AI assistant."},
        {"role": "user", "content": "Please explain artificial intelligence."}
    ]
});

console.log(completion.choices[0].message);

// Embedding
const embedding = await openai.chat.completions.create({
    model: "bge-m3",   // CLOVA Studio supported model name (embedding)
    input: "Thank you for using CLOVA Studio."    
});

console.log(embedding.data[0].embedding);
Note

You can use CLOVA Studio through open source frameworks implemented with OpenAI's official SDK and compatible APIs in various languages.

Compatibility information

This section provides detailed compatibility information for each API compatible with the OpenAI API. For the input format and scope of supported fields and CLOVA Studio-specific fields, see the relevant API guide.

Chat Completions/Chat Completions v3

The OpenAI compatibility information for Chat Completions API and Chat Completions v3 API is as follows:

Supported field Unsupported field CLOVA Studio-specific field
  • model
  • messages
  • stream
  • tools
  • tool_choice
  • temperature
  • max_tokens (default: 512)
  • max_completion_tokens (default: 512)
  • reasoning_effort | reasoning.effort
  • response_format
  • top_p
  • stop
  • seed
  • frequency_penalty
  • presence_penalty
  • store
  • metadata
  • logit_bias
  • logprobs
  • top_logprobs
  • n
  • name
  • modalities
  • prediction
  • audio
  • service_tier
  • stream_options
  • parallel_tool_calls
  • user
  • top_k
  • repeat_penalty
  • repetition_penalty

Embedding, Embedding v2

The OpenAI compatibility information for the Embedding API and Embedding v2 API is as follows:

Supported field Unsupported field CLOVA Studio-specific field
  • input
  • model
  • dimensions
  • encoding_format
  • user
-