次の方法で共有


AIProjectClient Class

AIProjectClient.

Constructor

AIProjectClient(endpoint: str, credential: AsyncTokenCredential, **kwargs: Any)

Parameters

Name Description
endpoint
Required
str

Foundry Project endpoint in the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you only have one Project in your Foundry Hub, or to target the default Project in your Hub, use the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". Required.

credential
Required

Credential used to authenticate requests to the service. Required.

Keyword-Only Parameters

Name Description
api_version
str

The API version to use for this operation. Known values are "v1" and None. Default value is "v1". Note that overriding this default value may result in unsupported behavior.

Variables

Name Description
beta

BetaOperations operations

agents

AgentsOperations operations

evaluation_rules

EvaluationRulesOperations operations

connections

ConnectionsOperations operations

datasets

DatasetsOperations operations

deployments

DeploymentsOperations operations

indexes

IndexesOperations operations

Methods

close
get_openai_client

Get an authenticated AsyncOpenAI client from the openai package.

Keyword arguments are passed to the AsyncOpenAI client constructor.

The AsyncOpenAI client constructor is called with:

  • base_url set to the endpoint provided to the AIProjectClient constructor, with "/openai/v1" appended. Can be overridden by passing base_url as a keyword argument.
  • api_key set to a get_bearer_token_provider() callable that uses the TokenCredential provided to the AIProjectClient constructor, with scope "https://ai.azure.com/.default". Can be overridden by passing api_key as a keyword argument.

Note

The packages openai and azure.identity must be installed prior to calling this method.

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client.send_request(request)
<AsyncHttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

close

async close() -> None

get_openai_client

Get an authenticated AsyncOpenAI client from the openai package.

Keyword arguments are passed to the AsyncOpenAI client constructor.

The AsyncOpenAI client constructor is called with:

  • base_url set to the endpoint provided to the AIProjectClient constructor, with "/openai/v1" appended. Can be overridden by passing base_url as a keyword argument.
  • api_key set to a get_bearer_token_provider() callable that uses the TokenCredential provided to the AIProjectClient constructor, with scope "https://ai.azure.com/.default". Can be overridden by passing api_key as a keyword argument.

Note

The packages openai and azure.identity must be installed prior to calling this method.

get_openai_client(**kwargs: Any) -> AsyncOpenAI

Returns

Type Description
<xref:openai.AsyncOpenAI>

An authenticated AsyncOpenAI client

Exceptions

Type Description

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client.send_request(request)
<AsyncHttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> Awaitable[AsyncHttpResponse]

Parameters

Name Description
request
Required

The network request you want to make. Required.

Keyword-Only Parameters

Name Description
stream

Whether the response payload will be streamed. Defaults to False.

Default value: False

Returns

Type Description

The response of your network call. Does not do error handling on your response.