This topic describes how to complete the following three steps: Confirm the model configuration, Create an API key, and Call a model. This way, you can quickly experience the AI service.
Overview
This topic will guide you through the basic initialization of AI services and how to validate model invocation capabilities using APIs or SQL.
Prerequisites
You have logged in to the OceanBase Cloud console and clicked AI Service in the left-side navigation pane to go to the AI Service page.
If you plan to call a model by using SQL, make sure that the target database meets the requirements for using AI functions and has the corresponding permissions. For more information, see Enable the AI function built-in AI models.
Create an API key
In the onboarding card, click Go to Create next to API Key to go to the API Key page.
Click Create API Key, enter a name of 2 to 64 characters in the dialog box. The name can contain only Chinese characters, digits, and letters, underscores (_), and hyphens (-). Also, select I have agreed to the agreement and understand the associated risks.
Click OK to copy and save the generated API key.
Note
After the API key is created, the complete API key is displayed only once. Make sure to copy and save it. You cannot view the complete content of the API key again later.
Confirm the model configuration
On the AI Service page, click Go to Configure next to Confirm Model Configuration in the onboarding card to go to the configuration page.
On the model page, select the default model for each task type as needed. For more information, see Built-in models.
Default modelDescriptionText generation For scenarios such as dialog generation, content creation, and Q&A. Text embedding Converts text into vectors for semantic search and similarity calculation. Text reranking Reranks the retrieved results to improve the quality of search results. Multi-modal embedding Converts multi-modal content such as images and text into vectors for cross-modal search. Multi-modal reranking Reranks the multi-modal retrieved results to improve the effectiveness of multi-modal search. Save the configuration.
After the configuration is completed, subsequent applications and databases can use these default models without additional configuration.
Call a model
After you complete the model configuration and create an API key, you can call a model in one of the following ways:
Call a model by using an API
This method is suitable for scenarios such as application services, backend systems, and external integrations.
In the onboarding card, view the Call Model section.
Click Call Model via API.
Use the API key to send an HTTP request to call a model, as shown in the following example.
For more information, see AI APIs.
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"}]}'
Call a model by using SQL
This method is suitable for scenarios such as text generation, embedding, and reranking in the database.
In the Call Model section, click Call Model via SQL.
Use the AI function in the database to call a model, as shown in the following example.
SELECT AI_COMPLETE("ob_complete","How are you") AS ans;
SELECT AI_EMBEDDING("ob_embed","I am OceanBase Cloud AI") AS embedding;
SELECT AI_RERANK("ob_rerank1","Apple",["apple","banana","fruit","vegetable"]) AS rerank_result;
You can also generate a database registration SQL statement on the model page and use it to register the AI model in the database. For more information, see Use AI models.
Verify the access
After you complete the preceding steps, you can verify whether the AI service is accessed in the following ways:
Call a model by using an API and confirm that the response is returned.
Call a model by using SQL and confirm that the AI function is executed.
On the AI Service overview page, check whether the token usage starts to increase.
