Creating an API Key

Create an API key to authenticate requests to OCI Generative AI. You can name the key and optionally configure up to two key names with expiration dates and times.

Important

Ensure that you Add API Key Permission after you create the key.
  • On the API keys list page, select Create API key. If you need help finding the list page, see Listing API Keys.

    Basic information

    1. Enter a Name for the API key (required). Start the name with a letter or underscore, followed by letters, numbers, hyphens, or underscores. The length can be 1–255 characters.
    2. (Optional) Enter a Description.
    3. (Optional) To save the API key in a different compartment than the one listed, select another Compartment.
      You must have permission to work in a compartment to see the resources in it. If you're not sure which compartment to use, contact an administrator. For more information, see Understanding Compartments.
    4. (Optional) Assign Tags to this API key. See Resource Tags.

    Key names and expiration times

    1. Enter a name for the first key: Key one name. Start the name with a letter or underscore, followed by letters, numbers, hyphens, or underscores. The length can be 1–255 characters.
    2. (Optional) Set the Key one expiration date and Key one expiration time (UTC).
      The default value is three months from the creation date.
    3. Enter a name for the second key: Key two name.
    4. (Optional) Set the Key two expiration date and Key two expiration time (UTC).
      The default value is three months from the creation date.
    5. Select Create.
    Ensure that you Add API Key Permission after you create the key.
  • Use the api-key create command and required parameters to create an API key.

    oci generative-ai api-key create [OPTIONS]

    For a complete list of parameters and values for CLI commands, see the CLI Command Reference.

  • Run the CreateApiKey operation to create an API key. Provide the display name, optional description, and any key names with their expiration timestamps (UTC).