블로그
API Guides2 분 읽기

OpenAI Compatible API: Complete Integration Guide

OpenAI Compatible API

AI API Hub provides a 100% OpenAI-compatible API endpoint. Use any OpenAI SDK or library without modification.

What "OpenAI Compatible" Means

Any tool built for the OpenAI API works with AI API Hub:

  • Official openai Python/Node.js SDK
  • LangChain OpenAI integration
  • LlamaIndex OpenAI integration
  • Any third-party library that accepts a base_url

Python Quick Start

import openai

# Only change: add base_url
client = openai.OpenAI(
    api_key="your-hub-key",
    base_url="https://api.apiyihe.org/v1"
)

# Everything else — identical
models = client.models.list()
for model in models:
    print(model.id)
# Output: gpt-4o, gpt-4o-mini, deepseek-v3, claude-3.5-sonnet, ...

JavaScript/Node.js

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "your-hub-key",
  baseURL: "https://api.apiyihe.org/v1",
});

const completion = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Say hello" }],
});

LangChain Integration

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-4o",
    openai_api_key="your-hub-key",
    openai_api_base="https://api.apiyihe.org/v1"
)

response = llm.invoke("Explain machine learning")

LlamaIndex Integration

from llama_index.llms.openai import OpenAI

llm = OpenAI(
    model="gpt-4o",
    api_key="your-hub-key",
    api_base="https://api.apiyihe.org/v1"
)

Supported Endpoints

All standard OpenAI endpoints are supported:

  • /v1/chat/completions
  • /v1/completions
  • /v1/embeddings
  • /v1/models

Supported Parameters

# All standard parameters work
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[...],
    temperature=0.7,
    top_p=0.9,
    max_tokens=2000,
    stream=True,
    functions=[...],
    response_format={"type": "json_object"}
)

Get Your API Key Now

Start building with 50+ AI models through one unified gateway.

계정 만들기
API 키 받기