This topic describes how to access AI services of OceanBase Cloud through AI APIs. The AI APIs support calling methods compatible with OpenAI, Anthropic, and Vertex AI. You can select an API based on the interface protocol, request format, and access habits of your existing application. You can reuse the existing calling logic to quickly complete model access and debugging.
Prerequisites
You have activated the AI service.
You have created a valid
API Key. For more information, see Manage AI API keys.
Calling method
You can call the AI API by using HTTP requests.
Place the API Key in the Authorization request header as required by the interface. Here is a general calling example:
curl -X POST https://api.example.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen3-max", "messages": [{"role": "user", "content": "Hello"}]}'
Response examples
- Successful call
{
"id": "req_xxx",
"object": "response",
"created": 1710000000,
"model": "example-model",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello, OceanBase Cloud AI."
}
}
]
}
- Failed call
{
"error": {
"code": "unauthorized",
"message": "Invalid API key."
}
}
