Invocation via API
Go to the Cloud Development Platform/Environment Configuration/API Key Configuration Page to create a new API Key.
After obtaining the API Key, you can perform HTTP API calls by simply including the Authorization: Bearer <Your API Key>
header in the HTTP request.
Available HTTP APIs include:
Large Model Invocation
cURL Example
Here is an example of using cURL to call the Large Model HTTP API:
curl -X POST 'https://your-env-id.api.tcloudbasegateway.com/v1/ai/deepseek/v1/chat/completions' \
-H 'Authorization: Bearer <Your API Key>' \
-H 'Content-Type: application/json' \
-H 'Accept: text/event-stream' \
-d '{
"model": "deepseek-r1",
"messages": [
{
"role": "user",
"content": "Introduce yourself"
}
],
"stream": true
}'
OpenAI SDK Example
After obtaining the API Key, you can also use the OpenAI SDK to access the large model service by simply replacing the baseURL
and apiKey
. Here is an example:
const OpenAI = require("openai");
const client = new OpenAI({
apiKey: "Your API Key",
baseURL: "https://your-env-id.api.tcloudbasegateway.com/v1/ai/deepseek/v1",
});
async function main() {
const completion = await client.chat.completions.create({
model: "deepseek-r1",
messages: [{ role: "user", content: "Hello" }],
temperature: 0.3,
stream: true,
});
for await (const chunk of completion) {
console.log(chunk);
}
}
main();
AI Agent Invocation
cURL Example
Here is an example of using cURL to call the AI Agent HTTP API:
curl 'https://<your-envId>.api.tcloudbasegateway.com/v1/aibot/bots/<your-botId>/send-message' \
-H 'Authorization: Bearer <Your API Key>' \
-H 'Accept: text/event-stream' \
-H 'Content-Type: application/json' \
--data-raw '{"msg":"hi"}'
Knowledge Base Invocation
cURL Example
Here is an example of using cURL to call the Knowledge Base HTTP API:
curl 'https://<your-envId>.api.tcloudbasegateway.com/v1/knowlege/send-message' \
-H 'Authorization: Bearer <Your API Key>' \
-H 'Accept: text/event-stream' \
-H 'Content-Type: application/json' \
-d '{
"collectionView": "ykfty_6fWO",
"search": {
"content": "What are the latest features of CloudBase AI+?",
"limit": "5"
}
}'