The AIProjectClient is the main class you instantiate to interact with your Foundry project.
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
project = AIProjectClient(
endpoint="<your-project-endpoint>",
credential=DefaultAzureCredential()
)
# Get an OpenAI-compatible client
openai_client = project.get_openai_client()
response = openai_client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello from Foundry!"}]
)
print(response.choices[0].message.content)
using Azure.AI.Projects;
using Azure.Identity;
var client = new AIProjectClient(
new Uri("<your-project-endpoint>"),
new DefaultAzureCredential()
);
var openAIClient = client.GetOpenAIClient();
https://<name>.services.ai.azure.com/api/projects/<project-id>