Application Process
To use the OpenAI Chat Completion API, first go to the Ace Data Cloud Console to obtain your API Token for backup.
If you are not logged in or registered, you will be automatically redirected to the login page to invite you to register and log in, and after completion, you will be automatically returned to the current page.
One API Token can call all services on the platform without needing to apply separately for each service. The first application will grant a free quota for a free experience; when the quota is insufficient, you can recharge the general balance in the console.
📘 Complete Documentation: OpenAI Chat Completion API →
Basic Usage
Next, you can fill in the corresponding content on the interface, as shown in the figure:
authorization, which can be selected directly from the dropdown list. The other parameter is model, which is the category of the OpenAI ChatGPT model we choose to use; here we mainly have 20 types of models, and details can be found in the models we provide. The last parameter is messages, which is an array of our input questions; it is an array that allows multiple questions to be uploaded simultaneously, with each question containing role and content, where role indicates the role of the questioner, and we provide three identities: user, assistant, and system. The other content is the specific content of our question.
You can also notice that there is corresponding code generation on the right side; you can copy the code to run directly or click the “Try” button for testing.
Common optional parameters:
max_tokens: Limits the maximum number of tokens for a single reply.temperature: Generates randomness, between 0-2, with larger values being more divergent.n: How many candidate replies to generate at once.response_format: Sets the return format.

id: The ID generated for this dialogue task, used to uniquely identify this dialogue task.model: The selected OpenAI ChatGPT model.choices: The response information provided by ChatGPT for the question.usage: Statistics on token usage for this Q&A.
choices contains the response information from ChatGPT, and within it, the choices is ChatGPT, as shown in the figure.

content field in choices contains the specific content of ChatGPT’s reply.
Streaming Response
This interface also supports streaming responses, which is very useful for web integration, allowing the webpage to achieve a word-by-word display effect. If you want to return responses in a streaming manner, you can change thestream parameter in the request header to true.
Modify as shown in the figure, but the calling code needs to have corresponding changes to support streaming responses.

stream to true, the API will return the corresponding JSON data line by line, and we need to make corresponding modifications at the code level to obtain the line-by-line results.
Python sample calling code:
data in the response, and the choices in data are the latest response content, consistent with the content introduced above. The choices are the newly added response content, which you can use to connect to your system. At the same time, the end of the streaming response is determined by the content of data. If the content is [DONE], it indicates that the streaming response has completely ended. The returned data result has multiple fields, which are described as follows:
id, the ID generated for this dialogue task, used to uniquely identify this dialogue task.model, the OpenAI ChatGPT model selected.choices, the response information provided by ChatGPT to the prompt.
Multi-turn Dialogue
If you want to connect to the multi-turn dialogue feature, you need to upload multiple prompts in themessages field. The specific examples of multiple prompts are shown in the image below:

choices is consistent with the basic usage content, which includes the specific content of ChatGPT’s responses to multiple dialogues, allowing for answers to corresponding questions based on multiple dialogue contents.
Integrating OpenAI-Python
The OpenAI Chat Completion API is compatible with the official OpenAI interface and can be directly integrated using the official SDK OpenAI-Python. This article will briefly introduce the usage.- First, set up a local
Pythonenvironment, which can be searched on Google. - Download and install a development environment, such as the VSCode editor.
- Configure the
OpenAIenvironment variables.
- In the project folder, create a file named
.envand save it. - The content of the
.envfile:
sk-xxx with your own key. OPENAI_BASE_URL is the proxy interface for accessing OpenAI.
- Install the project’s dependency packages.
- Create a sample source code file.
index.py, the specific content is as follows:
Online Model
The gpt-3.5-browsing and gpt-4-browsing models are different from other models; they can perform online searches based on the question words and return the results of the online search with appropriate adjustments. This article will demonstrate the online functionality through a specific example, and you can fill in the corresponding content on the OpenAI Chat Completion API interface, as shown in the figure:

choices is obtained based on online queries and also provides relevant links. The response information in choices needs to be rendered using markdown syntax to achieve the best experience, which ultimately reflects the powerful advantages of our model’s online functionality.
Visual Model
gpt-4o is a multimodal large language model developed by OpenAI, which adds visual understanding capabilities on the basis of GPT-4. This model can process both text and image inputs simultaneously, achieving cross-modal understanding and generation. The text processing using the gpt-4o model is consistent with the basic usage content mentioned above. Below, we will briefly introduce how to use the model’s image processing capabilities. The image processing capability of the gpt-4o model is mainly achieved by adding atype field to the original content, which indicates whether the uploaded content is text or an image, thus utilizing the image processing capabilities of the gpt-4o model. Below, we will mainly discuss how to call this function using both Curl and Python.
- Curl script method
- Python script method
GPT-4o Drawing Model
Generate Images Based on Reference Images
Below is an example of generating a custom style image based on a picture. First, let’s take a look at the input image, as shown below:
It can be seen that the reference image is a real person’s picture. We can ask it to change to a certain style, for example, to turn it into an anime-style image, with the specific request example:
choices in the message.content is the complete dialogue result generated, and the image is included in Markdown format (the image link is a temporary address, please download and save it in time). It can be seen that the generated image is indeed in anime style, as shown in the following image:

Pure Text Image Generation
We can generate an image through a prompt and return it to us in a conversational result. Below, we takecreate an image of a futuristic city at sunset as an example, with the specific example as follows:

Generate One Image from Multiple Images
We can also use multiple reference images to generate one image. For example, using a handsome guy and a coffee image, these two images can be used to generate an image of a handsome guy drinking coffee. Below are the specific reference images:

generate an image of a boy holding coffee and about to drink as an example, with the specific example as follows:

Error Handling
When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:400 token_mismatched: Bad request, possibly due to missing or invalid parameters.400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.401 invalid_token: Unauthorized, invalid or missing authorization token.429 too_many_requests: Too many requests, you have exceeded the rate limit.500 api_error: Internal server error, something went wrong on the server.

