Azure OpenAI

pydantic model llama_index.llms.azure_openai.AzureOpenAI

Azure OpenAI

To use this, you must first deploy a model on Azure OpenAI. Unlike OpenAI, you need to specify a engine parameter to identify your deployment (called β€œmodel deployment name” in Azure portal).

  • model: Name of the model (e.g. text-davinci-003)

    This in only used to decide completion vs. chat endpoint.

  • engine: This will correspond to the custom name you chose

    for your deployment when you deployed a model.

You must have the following environment variables set: - OPENAI_API_TYPE: set this to azure, azure_ad, or azuread - OPENAI_API_VERSION: set this to 2023-05-15

This may change in the future.

More information can be found here:

https://learn.microsoft.com/en-us/azure/cognitive-services/openai/quickstart?tabs=command-line&pivots=programming-language-python

Show JSON schema
{
   "title": "AzureOpenAI",
   "description": "Azure OpenAI\n\nTo use this, you must first deploy a model on Azure OpenAI.\nUnlike OpenAI, you need to specify a `engine` parameter to identify\nyour deployment (called \"model deployment name\" in Azure portal).\n\n- model: Name of the model (e.g. `text-davinci-003`)\n    This in only used to decide completion vs. chat endpoint.\n- engine: This will correspond to the custom name you chose\n    for your deployment when you deployed a model.\n\nYou must have the following environment variables set:\n- `OPENAI_API_TYPE`: set this to `azure`, `azure_ad`, or `azuread`\n- `OPENAI_API_VERSION`: set this to `2023-05-15`\n    This may change in the future.\n- `OPENAI_API_BASE`: your endpoint should look like the following\n    https://YOUR_RESOURCE_NAME.openai.azure.com/\n- `OPENAI_API_KEY`: your API key\n\nMore information can be found here:\n    https://learn.microsoft.com/en-us/azure/cognitive-services/openai/quickstart?tabs=command-line&pivots=programming-language-python",
   "type": "object",
   "properties": {
      "callback_manager": {
         "title": "Callback Manager"
      },
      "model": {
         "title": "Model",
         "description": "The OpenAI model to use.",
         "type": "string"
      },
      "temperature": {
         "title": "Temperature",
         "description": "The tempature to use during generation.",
         "type": "number"
      },
      "max_tokens": {
         "title": "Max Tokens",
         "description": "The maximum number of tokens to generate.",
         "type": "integer"
      },
      "additional_kwargs": {
         "title": "Additional Kwargs",
         "description": "Additonal kwargs for the OpenAI API.",
         "type": "object"
      },
      "max_retries": {
         "title": "Max Retries",
         "description": "The maximum number of API retries.",
         "type": "integer"
      },
      "api_key": {
         "title": "Api Key",
         "description": "The OpenAI API key.",
         "type": "string"
      },
      "api_type": {
         "title": "Api Type",
         "description": "The OpenAI API type.",
         "type": "string"
      },
      "api_base": {
         "title": "Api Base",
         "description": "The base URL for OpenAI API.",
         "type": "string"
      },
      "api_version": {
         "title": "Api Version",
         "description": "The API version for OpenAI API.",
         "type": "string"
      },
      "class_type": {
         "title": "Class Type",
         "default": "openai",
         "type": "string"
      },
      "engine": {
         "title": "Engine",
         "description": "The name of the deployed azure engine.",
         "type": "string"
      }
   },
   "required": [
      "model",
      "temperature",
      "max_retries",
      "api_base",
      "api_version",
      "engine"
   ]
}

Config
  • arbitrary_types_allowed: bool = True

Fields
Validators
  • _validate_callback_manager Β» callback_manager

  • validate_env Β» all fields

field engine: str [Required]

The name of the deployed azure engine.

Validated by
classmethod class_name() str

Get class name.

validator validate_env  Β»  all fields

Validate necessary credentials are set.