02 First Model Call
Goal
Confirm your Foundry endpoint, authentication, and deployed model all work from Python.
Estimated time
10 minutes.
Official references
- Microsoft Foundry get-started code quickstart
- Microsoft Foundry SDKs and Endpoints
- Azure SDK for Python responses samples
Exercise
Run the example:
python examples/01-model-call/model_call.py
This example is using the Responses API. The script first connects to your Foundry project with AIProjectClient, then asks that project client for an OpenAI-compatible client, and finally sends a responses.create(...) call to your deployed model.
Example file
What this lab demonstrates
- Create an
AIProjectClientwithDefaultAzureCredential. - Get the OpenAI-compatible client from the project.
- Send a
responses.create(...)request. - Print the generated answer.
What is happening under the hood
AZURE_AI_PROJECT_ENDPOINTpoints to your Foundry project endpoint, not directly to a raw model endpoint.AIProjectClienthandles the Foundry-side connection and authentication usingDefaultAzureCredential.project.get_openai_client()returns an OpenAI-compatible client that can call model features exposed through your Foundry project.responses.create(...)sends your input prompt to the deployed model named inAZURE_AI_MODEL_DEPLOYMENT_NAME.response.output_textprints the final text returned by the model.
This is a useful first lab because it proves the full path is working: local Python environment, Azure authentication, Foundry project endpoint, deployed model, and the OpenAI-compatible Responses API surface.
Expected result
You should see a short response describing common PCR use cases in life sciences.
Verification
- The script runs without authentication errors.
- The script returns model output.
- The project endpoint in
.envis valid.
Common issues
DefaultAzureCredential failed to retrieve a token: sign in again withaz login.404 Not Found: check your project endpoint format.- SDK mismatch errors: verify
azure-ai-projects>=2.0.0.