OpenAI official library usage tutorial
Our API is fully compatible with the OpenAI interface protocol and supports seamless integration with various applications that utilize the OpenAI interface.Note: All chat models (including non-OpenAI models) support the official OpenAI library. Please ensure that the request URL and format adhere to OpenAI's request method.Reference: Official development documentation.When making requests to the interface, replace https://api.openai.com with our API address (which can be found in the API website -> Console). Your KEY must correspond with the API website, so be careful not to mix up mixed sites with official transition sites. OpenAI official Python library#
Official project address
⚠️ Note: Please upgrade the openai library to version 1.25+ or the latest version, otherwise any call errors will not be supported.Installation#
DEMO:#
Note: base_url needs to include the /v1/ suffix.import os
import openai
openai.api_key = "apikey"
openai.base_url = "https://api.getgoapi.com/v1/"
openai.default_headers = {"x-foo": "true"}
completion = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "Hello world!",
},
],
)
print(completion.choices[0].message.content)
#It usually outputs results.:Hello there! How can I assist you today ?`
Modified at 2025-05-22 03:58:27