Baiyun Super Intelligence BAIYUN.SI
API integration tutorial

Baiyun API tutorial: Chat text interface

Free to read

Example of Chat Completions synchronizing with SSE streaming, plain text requests. Includes complete inspection steps, practical verification, and error handling.

Chat Completions text interface

Interface Address:POST https://api.baiyun.si/v1/chat/completions。

Currently, Chat-style plain text conversations are available for clients that explicitly support OpenAI's Chat protocol. Request to use the site key and submit the full text context required for this conversation.

Request structure

json
{
  "model": "gpt-6-luna",
  "messages": [
    {"role": "system", "content": "用简洁的中文回答。"},
    {"role": "user", "content": "请解释什么是 Token。"}
  ],
  "stream": false
}

model This is the name of the model actually available on this site;messages Text messages submitted in order;stream Decide whether to return synchronously or stream. This article only presents the open basic text structure; complex SDK parameters and extension features should not be available by default.

Synchronous call

bash
curl --fail-with-body https://api.baiyun.si/v1/chat/completions \
  -H "Authorization: Bearer $BAIYUN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model":"gpt-6-luna","messages":[{"role":"user","content":"用一句话解释 Token。"}],"stream":false}'

Generated text is located at choices[].message.content; Dosage information is located here usage。 Specific content, number of tokens, and fees are subject to the actual response and consumption records of this time.

Stream calls

bash
curl --no-buffer --fail-with-body https://api.baiyun.si/v1/chat/completions \
  -H "Authorization: Bearer $BAIYUN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gpt-6-luna",
    "messages":[{"role":"user","content":"用三句话介绍 Token。"}],
    "stream":true,
    "stream_options":{"include_usage":true}
  }'

Stream returns using SSE: read data: JSON, concatenate them in order choices[].delta.content。data: [DONE] Indicates the end of the stream; Activated include_usage The usage message at the end must be kept afterward. Do not treat every SSE shard as a standalone HTTP response.

Dialogue context and parameter boundaries

The current channel uses the model's default sampling.temperature、top_p、frequency_penalty And presence_penalty Adjustable controls are not provided at this time; Common default values on the client side are removed by compatibility processing and do not change the model's sampling settings.

Multiple rounds of dialogue should be present messages Submit the required complete text history. Currently, external tools, networking, images, and file functions are suspended, and there is no way to bypass text submissions through unchecked external history.

Some models or clients support output parameters differently. Even if you ask to fill it out max_tokens、max_completion_tokens Or values like 8192, etcIt cannot be regarded as a fixed output length or cost limit guaranteed by this site。 Start with a brief request, verify your spending records, and set balance limits for your keys that suit you.

The same voucher can be processed at most simultaneously 2 requests; Model calls are also limited by frequency. If you encounter 429, wait and press itMisstatementIdentify the cause and avoid high-frequency loop retrys.

Checklist before practical use

  1. Prepare your own account and access keys, and do not use others' shared credentials.
  2. Records client versions, systems, and models to be used for easy reproduction during troubleshooting.
  3. Save the original configuration or screenshot, hide keys, verification codes, and private content.
  4. Confirm that testing may consume a small amount of DK, starting with a single sentence and a single request.
  5. Review the current model plaza and status page before deciding whether to enable more features.

Detailed investigation: narrow down the scope of the problem in order

First, confirm that the account is complete, the key is valid, and the DK balance is sufficient, then verify the protocol, address, and model. Make a minimum text request using the same key; Only after it succeeds does it restore attachments, tools, or automatically retry each item. After saving the client configuration, reopen the session to avoid using the previous vendor in the old session.

How to confirm that this section has been learned

Don't just check the "Configuration saved successfully" prompt. You should be able to clearly state the current Base URL, key usage, chosen model, and request protocol, and be able to verify your operation results on the corresponding console. The client-side tutorial uses a single actual plain text response and corresponding logs as the initial completion standard; Account tutorials are based on comprehensive security information; The billing tutorial uses the correspondence between principal, channel fees, and DK as the standard.

If an error occurs, record the occurrence time, HTTP status, content of the anonymized error, and the actual expected result. Do not screenshot the entire page key, and do not give the password or verification code to others. For 401, authentication should be resolved first; for 400, parameters should be resolved first; for 429, intensive retries should be stopped; for 404, request paths and upstream verification should be verified; recharging cannot resolve all errors.

A small task suitable for practice

Complete the minimum steps in this section in your own testing environment, recording in text "how you originally set it, which item you modified, and what results you saw." Do not treat production data, real payments, or irrecoverable commands as exercises. If you encounter features beyond what this section offers, first check the corresponding protocol tutorial before considering adding features; Changing only one configuration at a time makes it easy to judge which step leads to errors.

The next step is the boundary of the version

Return to the full learning map · Streamlined API site configuration · Real-time status of this site。

The tutorial was compiled on October 9, 2026. The specific interface and capabilities may vary depending on the client and upstream versions; The configuration guidelines do not mean that all client versions have passed the test. For balance payments, QQ / Alipay login, and open channels, please refer to the actual page page; Compression interfaces: Previously, upstream 404 and raw image channels were not available, so don't assume configuration files can be automatically removed.

Once you've learned it, give it a try.

Use SIN1's 100 questions to check your foundation.

Take the test

Contact Baiyun SI Community

Contact via email.

For inquiries, needs exchange, or cooperation discussions, please send an email.