Obtain ApiKey
What is ApiKey
ApiKeyis similar toAccessToken, and is a security Token` used for user authentication.
Differences between ApiKeyandAccessToken`:
ApiKeybelongs to the B-end identity, which is the developer identity, with administrator-level permissions, whileAccessTokenobtained via login belongs to the C-end identity, with ordinary user-level permissions.ApiKeyis typically used on the server-side, whileAccessTokenis typically used on the client-side.ApiKeyis typically long-term valid, whileAccessTokenis usually short-term valid and requires regular refreshing withRefreshToken.
How to obtain ApiKey?
- Go to CloudBase and select the corresponding environment
- Go to
Environment Configuration->ApiKey Management Page->Create ApiKeyto obtainApiKey
How to use ApiKey?
Similar to AccessToken, when making API calls, include ApiKey in the request header.
Authorization: Bearer <ApiKey>
If using the openai SDK to call large model APIs, you can pass ApiKey when initializing the OpenAI instance.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: `your-apui-key`,
});