# AzureApiManagementResource.AddOpenAIApi

- Module: [Aspire.Hosting.Azure.ApiManagement](/reference/api/go/aspire.hosting.azure.apimanagement.md)
- Defined on: [AzureApiManagementResource](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementresource.md)
- Version: `17.0.0-preview.1.26567.5`
- Kind: `method`

Adds an OpenAI-compatible API backed by an API Management load-balancing pool.

## Remarks

Create backends with `AddAzureOpenAIBackend` or `AddFoundryBackend`,
compose them with `AddBackendPool`, and attach the pool with `WithBackend`.
Requests beneath `path` are appended to the selected backend URI.

## Definition

```go
type AzureApiManagementResource interface {
    // ... omitted for brevity
    AddOpenAIApi(
        name string,
        path string,
        options ...*AddOpenAIApiOptions,
    ) AzureApiManagementApiResource
}
```

## Signature

```go
AddOpenAIApi(
    name string,
    path string,
    options ...*AddOpenAIApiOptions,
) AzureApiManagementApiResource
```

## Parameters

- `name` (`string`) -- The globally unique Aspire resource name and default physical API name.
- `path` (`string`) -- The public path beneath the API Management gateway hostname.
- `options` (`...*AddOpenAIApiOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*AddOpenAIApiOptions` argument.

- `DisplayName` (`*string`) -- The API display name. The resource name is used when omitted.
- `SubscriptionRequired` (`*bool`) -- Whether callers must provide an API Management subscription key. The default is `true`.
- `ApiName` (`*string`) -- The physical API identifier in API Management. The Aspire resource name is used when omitted.

## Returns

[`AzureApiManagementApiResource`](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementapiresource.md) -- A builder for the API resource.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [AzureApiManagementResource](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementresource.md) -- `handle`
