Skip to content

Create my project and call the API

A project of your own, a model deployed in it, an endpoint: that is all it takes to call AI from your code. The project is created in the existing Foundry resource, never in a new resource — that would be a full-fledged Azure lab, with its own Resource Group, tags and declaration.

  1. Open the labs Foundry project, then create a project from the project selector. The suggested resource must be aif-azurefoundry-lab-szn: it holds the lab’s quotas and bill.

  2. Give the project a recognizable name, your trigram followed by the topic: proj-qro-extraction-factures. The resource is shared, and nobody should have to ask who owns this project. Same spirit as lab naming.

  3. Deploy a model from the model catalog. The deployment name is the one your code will use: keep the model name, without embellishing it.

  4. Choose the deployment type knowingly: that is where cost and processing location are decided, see just below.

  5. Copy the project endpoint, shown on the project home page. It looks like this:

    https://aif-azurefoundry-lab-szn.services.ai.azure.com/api/projects/<your-project>

The deployment type decides cost and location

Section titled “The deployment type decides cost and location”
The type How it is billed Where your prompts are processed
Global Standard Per token, nothing without calls. The widest catalog and the lowest price. Any geography where the model is deployed, so outside Switzerland and outside Europe.
Data zone Standard Per token, nothing without calls. Within the resource’s data zone, without leaving it.
Standard (regional) Per token, nothing without calls. Within the resource’s geography. The catalog is narrowest there.
Provisioned By the hour, calls or not, as long as the deployment exists. Depends on the chosen variant.
Batch Per token, roughly half price, asynchronous. Global processing.

For a test, Global Standard is the default choice: nothing to pay as long as you don’t make calls. A provisioned deployment is an hourly commitment, not to be created without prior approval from lab@qiminfo.ch.

Authentication uses your Qim info account, via Azure CLI: no key to store, no key to leak.

  1. Sign in. If your Azure CLI session is open on another tenant, add --tenant with the labs tenant.

    Terminal window
    az login
  2. Install the client and set the endpoint.

    Terminal window
    pip install "azure-ai-projects>=2.3.0" azure-identity
    export AZURE_AI_PROJECT_ENDPOINT="https://aif-azurefoundry-lab-szn.services.ai.azure.com/api/projects/proj-qro-extraction-factures"
  3. Call the model. The model parameter expects the name of your deployment, not that of the catalog model — they look alike, and it is the number one cause of 404s.

    import os
    from azure.ai.projects import AIProjectClient
    from azure.identity import DefaultAzureCredential
    project = AIProjectClient(
    endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential(),
    )
    client = project.get_openai_client()
    response = client.responses.create(
    model="gpt-5-mini",
    input="Summarize in three sentences what an Azure Resource Group is.",
    )
    print(response.output_text)

To check access without writing any code, a token and a request are enough.

Terminal window
TOKEN=$(az account get-access-token --scope https://ai.azure.com/.default --query accessToken -o tsv)
curl -X POST "$AZURE_AI_PROJECT_ENDPOINT/openai/v1/responses" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-5-mini", "input": "Hello"}'

The Foundry SDKs changed their API between versions 1.x and 2.x, and the examples floating around the web mix the two. Your project’s playground shows the code matching what is deployed, in the language of your choice: it is the only reference that never goes stale.

The symptom What is happening
The portal wants to create a new resource You are in the full creation flow, not the project one. Start again from the aif-azurefoundry-lab-szn resource and create the project inside it.
404 on the model name model expects the deployment name as it appears in your project, and the deployment must be in the project targeted by the endpoint.
401 despite az login Your session is open on another tenant or another account: az account show will tell you. Run az login again with --tenant.
403 while the playground works The portal and the SDK don’t go through the same permissions. Write to lab@qiminfo.ch with the project name.
The deployment fails for lack of quota The resource’s tokens-per-minute quota is already allocated to existing deployments. Lower the requested quota, or ask lab@qiminfo.ch to arbitrate.
The model you want isn’t offered It doesn’t exist in the resource’s region, or not with the chosen deployment type. A Global type often widens the catalog.
The bill climbs while nothing is running A provisioned deployment, a hosted fine-tuned model, or a test loop left running. Check the project’s list of deployments before looking anywhere else.

Nothing expires on its own. Delete the deployments first, then the project: that is what stops billing and frees up quota for your colleagues.

What matters is kept elsewhere: your prompts, test sets and scripts belong in a Git repository. No backup is guaranteed in the lab, and a deleted project takes its conversations with it.

Applicable rules

No sensitive data

My responsibility

Never put real client data, personal data or any sensitive data in a lab.

MandatoryPR-GOVCLOUDLAB-A-01 / PR-GOVLABONPREM-A-01

Indicative budget

Recommendation

Indicative budget of about 200 CHF per month per lab.

Not blockingPR-GOVCLOUDLAB-A-01

Clean up and document

My responsibility

Stop or delete unused resources, and document the lab as you go.

Not blockingPR-GOVCLOUDLAB-A-01

A need beyond self-service — a missing model, a larger quota, a provisioned deployment, fine-tuning, a connection to internal data: write to lab@qiminfo.ch describing the test and how long it will last.