Swift Examples - Azure Swift Client Library Examples

How to use OpenAI through an Azure deployment

You can use all of the OpenAI snippets with one change. Initialize the OpenAI service with:

import AIProxy

let openAIService = AIProxy.openAIService(
    partialKey: "partial-key-from-your-developer-dashboard",
    serviceURL: "service-url-from-your-developer-dashboard",
    requestFormat: .azureDeployment(apiVersion: "2024-06-01")
)

How to use Anthropic through an Azure deployment

You can use all of the Anthropic snippets with one change. Add the aiproxy-key-format header to your requests:

try await anthropicService.messageRequest(
    body: requestBody,
    secondsToWait: 120,
    additionalHeaders: [
        "aiproxy-key-format": "x-api-key: {{key}}"
    ]
)