|
| 1 | +--- |
| 2 | +title: How to use image models with Azure AI model inference |
| 3 | +titleSuffix: Azure AI Foundry |
| 4 | +description: Learn how to generate images with image models with Azure AI model inference |
| 5 | +manager: scottpolly |
| 6 | +author: msakande |
| 7 | +reviewer: Frogglew |
| 8 | +ms.service: azure-ai-model-inference |
| 9 | +ms.topic: how-to |
| 10 | +ms.date: 04/29/2025 |
| 11 | +ms.author: mopeakande |
| 12 | +ms.reviewer: saoh |
| 13 | +ms.custom: references_regions, tool_generated |
| 14 | +zone_pivot_groups: azure-ai-inference-samples |
| 15 | +--- |
| 16 | + |
| 17 | +This article explains how to generate images with _image_ models deployed to Azure AI model inference in Azure AI services. Some models have unique parameters or data format requirements. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +To use image models in your application, you need: |
| 22 | + |
| 23 | +[!INCLUDE [how-to-prerequisites](../includes/how-to-prerequisites.md)] |
| 24 | + |
| 25 | +* An image model deployment. If you don't have one, see [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add an image model to your resource. |
| 26 | + |
| 27 | + * This article uses `Mistral OCR`. |
| 28 | + |
| 29 | +## Use image model |
| 30 | + |
| 31 | +1. Authenticate using API key. For serverless API endpoints, deploy the model to generate the endpoint URL and an API key to authenticate against the service. In this example, the endpoint and key are strings holding the endpoint URL and the API key. The API endpoint URL and API key can be found on the **Deployments + Endpoint** page once the model is deployed. |
| 32 | + |
| 33 | + If you're using bash: |
| 34 | + |
| 35 | + ``` |
| 36 | + export AZURE_API_KEY = "<your-api-key>" |
| 37 | + ``` |
| 38 | + |
| 39 | + If you're in powershell: |
| 40 | + |
| 41 | + ``` |
| 42 | + $Env:AZURE_API_KEY = "<your-api-key>" |
| 43 | + ``` |
| 44 | + |
| 45 | + If you're using Windows command prompt: |
| 46 | + |
| 47 | + ``` |
| 48 | + export AZURE_API_KEY = "<your-api-key>" |
| 49 | + ``` |
| 50 | + |
| 51 | +1. Run a basic code sample. Paste the following code into a shell. |
| 52 | + |
| 53 | +> [!NOTE] |
| 54 | +> Different image models accept different data formats. In this example, `Mistral OCR 25.03` supports only base64 data. Document url or image url isn't supported. |
| 55 | +
|
| 56 | + ```http |
| 57 | + curl --request POST \ |
| 58 | + --url https://<your_serverless_endpoint>/v1/ocr \ |
| 59 | + --header 'Authorization: <api_key>' \ |
| 60 | + --header 'Content-Type: Application/json' \ |
| 61 | + --data '{ |
| 62 | + "model": "mistral-ocr-2503", |
| 63 | + "document": { |
| 64 | + "type": "document_url", |
| 65 | + "document_name": "test", |
| 66 | + "document_url": "data:application/pdf;base64,JVBER..." |
| 67 | + } |
| 68 | + }' |
| 69 | + ``` |
| 70 | + |
| 71 | +## Model specific requirements |
| 72 | + |
| 73 | +Some models only support specific data format. The following table list the supported and unsupported data formats for models. |
| 74 | + |
| 75 | +| Model | Supported | Not supported | |
| 76 | +| :---- | ----- | ----- | |
| 77 | +| Mistral OCR 25.03 | base64 only | document url or image url | |
| 78 | +| dall-e-3 | Must be one of url or b64_json | base64 | |
| 79 | +| gpt-image-1 | base64 only | document url or image url | |
| 80 | + |
| 81 | + |
| 82 | +## Related content |
| 83 | + |
| 84 | +* [Use embeddings models](use-embeddings.md) |
| 85 | +* [Azure AI Model Inference API](.././reference/reference-model-inference-api.md) |
0 commit comments