OpenAI Compatible Interface

Most OpenAI model API interfaces are supported, with all parameters and usage methods identical to OpenAI. For documentation, please refer to the OpenAI Official API Documentation, which can be used directly without any modifications.

TIP

Note: The platform forwarding is based on load balancing technology and randomly distributes requests across multiple accounts. Stateful interfaces such as file, fine-tune, and assistants are not supported. The response API is supported, but passing the ID from a previous round of responses (stateful usage) is not supported.

curl Request

curl https://ai-gate.haozcloud.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxx" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Official OpenAI Python Library

Note the differences between the new and old versions of the openai library

from openai import OpenAI

client = OpenAI(
    base_url='https://ai-gate.haozcloud.com/v1',
    api_key='sk-xxxxxxxx',
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say hi",
        }
    ],
    model="gpt-3.5-turbo",
)
WARNING

Some outdated documentation may provide examples with the engine field, which has been deprecated. Direct calls to openai can still work because openai maintains backward compatibility for legacy code, but the platform does not support these deprecated interface formats.

LangChain

Configure the API endpoint and token provided by this platform in your environment variables to use multiple models including gpt-3.5-turbo, text-davinci-003, text-embedding-ada-002, and more.

os.environ["OPENAI_API_BASE"] = "https://ai-gate.haozcloud.com/v1"
os.environ["OPENAI_API_KEY"] = "sk-xxxxxxxx"