1. Authentication using API Key
For Serverless API Endpoints, deploy the Model to generate the endpoint URL and an API key to authenticate against the service. In this sample endpoint and key are strings holding the endpoint URL and the API Key. The API endpoint URL and API key can be found on the Deployments + Endpoint page once the model is deployed.

If you're using bash:

export AZURE_API_KEY="<your-api-key>"

If you're in powershell:

$Env:AZURE_API_KEY = "<your-api-key>"

If you're using Windows command prompt:

export AZURE_API_KEY="<your-api-key>"

2. Run a basic code sample
Paste the following into a shell

curl -X POST "https://rmildlyinteresting-ai-resource.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $AZURE_API_KEY" \
    -d '{
        "messages": [
            {
                "role": "user",
                "content": "I am going to Paris, what should I see?"
            }
        ],
        "max_tokens": 2048,
        "temperature": 0.8,
        "top_p": 0.1,
        "presence_penalty": 0,
        "frequency_penalty": 0,
        "model": "Llama-3.2-90B-Vision-Instruct"
    }'

3. Explore more samples
Run a multi-turn conversation
Call the chat completion API and pass the chat history:

curl -X POST "https://rmildlyinteresting-ai-resource.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $AZURE_API_KEY" \
    -d '{
        "messages": [
            {
                "role": "user",
                "content": "I am going to Paris, what should I see?"
            },
            {
                "role": "assistant",
                "content": "Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:\n \n 1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.\n 2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.\n 3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.\n \n These are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world."
            },
            {
                "role": "user",
                "content": "What is so great about #1?"
            }
        ],
        "max_tokens": 2048,
        "temperature": 0.8,
        "top_p": 0.1,
        "presence_penalty": 0,
        "frequency_penalty": 0,
        "model": "Llama-3.2-90B-Vision-Instruct"
    }'

Stream the output
This is an example of calling the endpoint and streaming the response.

curl -X POST "https://rmildlyinteresting-ai-resource.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $AZURE_API_KEY" \
    -d '{
        "messages": [
            {
                "role": "user",
                "content": "I am going to Paris, what should I see?"
            }
        ],
        "stream": true,
        "max_tokens": 2048,
        "temperature": 0.8,
        "top_p": 0.1,
        "presence_penalty": 0,
        "frequency_penalty": 0,
        "model": "Llama-3.2-90B-Vision-Instruct"
    }'