Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions python/samples/getting_started/multimodal_input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,44 @@ This folder contains examples demonstrating how to send multimodal content (imag
- **Description**: Shows how to send multimodal content to Azure OpenAI service
- **Supported formats**: PNG/JPEG images, WAV/MP3 audio, PDF documents

## Running the Examples
## Environment Variables

Set the following environment variables before running the examples:

**For OpenAI:**
- `OPENAI_API_KEY`: Your OpenAI API key

**For Azure OpenAI:**
- `AZURE_OPENAI_ENDPOINT`: Your Azure OpenAI endpoint
- `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`: The name of your Azure OpenAI chat model deployment

1. Set your API keys:
Optionally for Azure OpenAI:
- `AZURE_OPENAI_API_VERSION`: The API version to use (default is `2024-10-21`)
- `AZURE_OPENAI_API_KEY`: Your Azure OpenAI API key (if not using `AzureCliCredential`)

```bash
export OPENAI_API_KEY="your-openai-key"
export AZURE_OPENAI_API_KEY="your-azure-key"
export AZURE_OPENAI_ENDPOINT="your-azure-endpoint"
```
**Note:** You can also provide configuration directly in code instead of using environment variables:
```python
# Example: Pass deployment_name directly
client = AzureOpenAIChatClient(
credential=AzureCliCredential(),
deployment_name="your-deployment-name",
endpoint="https://your-resource.openai.azure.com"
)
```

2. Run an example:
```bash
python openai_chat_client_multimodal.py
python azure_chat_client_multimodal.py
```
## Authentication

The Azure example uses `AzureCliCredential` for authentication. Run `az login` in your terminal before running the example, or replace `AzureCliCredential` with your preferred authentication method (e.g., provide `api_key` parameter).

## Running the Examples

```bash
# Run OpenAI example
python openai_chat_multimodal.py

# Run Azure example (requires az login or API key)
python azure_chat_multimodal.py
```

## Using Your Own Files

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

async def test_image() -> None:
"""Test image analysis with Azure."""
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option. Requires AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
# environment variables to be set.
# Alternatively, you can pass deployment_name explicitly:
# client = AzureOpenAIChatClient(credential=AzureCliCredential(), deployment_name="your-deployment-name")
client = AzureOpenAIChatClient(credential=AzureCliCredential())

# Fetch image from httpbin
Expand Down