Vision
Models that support vision can accept images alongside text in messages[].content. Provide one or more image_url parts, optionally with a detail hint, and the model will describe, read, or reason about the visual content.
Endpoint:
POST https://api.aifoundryhub.com/v1/chat/completions
Quick start — describe an image
Section titled “Quick start — describe an image”curl -X POST "https://api.aifoundryhub.com/v1/chat/completions" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5", "max_tokens": 200, "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this room in two sentences." }, { "type": "image_url", "image_url": { "url": "https://images.example.com/living-room.jpg", "detail": "auto" } } ] } ] }'import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.AI_FOUNDRY_HUB_API_KEY, baseURL: "https://api.aifoundryhub.com/v1",});
const resp = await client.chat.completions.create({ model: "gpt-5", max_tokens: 200, messages: [ { role: "user", content: [ { type: "text", text: "Describe this room in two sentences." }, { type: "image_url", image_url: { url: "https://images.example.com/living-room.jpg", detail: "auto" } } ] } ]});
console.log(resp.choices[0].message.content[0].text);package main
import ( "context" "fmt" "os"
openai "github.com/openai/openai-go" "github.com/openai/openai-go/option")
func main() { client := openai.NewClient( option.WithAPIKey(os.Getenv("AI_FOUNDRY_HUB_API_KEY")), option.WithBaseURL("https://api.aifoundryhub.com/v1"), )
ctx := context.Background() params := openai.ChatCompletionNewParams{ Model: "gpt-5", Messages: []openai.ChatCompletionMessageParamUnion{{ OfUser: &openai.ChatCompletionUserMessageParam{ Content: openai.ChatCompletionUserMessageParamContentUnion{ OfArrayOfContentParts: []openai.ChatCompletionContentPartUnionParam{ {OfText: &openai.ChatCompletionContentPartTextParam{Type: "text", Text: "What's in this image?"}}, {OfImageURL: &openai.ChatCompletionContentPartImageParam{ Type: "image_url", ImageURL: openai.ChatCompletionContentPartImageImageURLParam{ URL: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg", }, }}, }, }, }}, } resp, err := client.Chat.Completions.New(ctx, params) if err != nil { panic(err) } if len(resp.Choices) > 0 && len(resp.Choices[0].Message.Content) > 0 { fmt.Println(resp.Choices[0].Message.Content[0]) }}import osfrom openai import OpenAI
client = OpenAI( api_key=os.getenv("AI_FOUNDRY_HUB_API_KEY"), base_url="https://api.aifoundryhub.com/v1",)
resp = client.chat.completions.create( model="gpt-5", max_tokens=200, messages=[{ "role": "user", "content": [ {"type": "text", "text": "Describe this room in two sentences."}, {"type": "image_url", "image_url": {"url": "https://images.example.com/living-room.jpg", "detail": "auto"}} ] }])
print(resp.choices[0].message.content[0].text)Tip:
detail: "high"is best for small text (fine print). Usedetail: "low"when speed/cost matter more than precision.
Multi-image reasoning
Section titled “Multi-image reasoning”Pass several image_url parts in a single message to compare or reason across images.
curl -X POST "https://api.aifoundryhub.com/v1/chat/completions" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5", "messages": [{ "role": "user", "content": [ {"type":"text","text":"Are these outfits the same color palette? Explain differences."}, {"type":"image_url","image_url":{"url":"https://images.example.com/look1.jpg"}}, {"type":"image_url","image_url":{"url":"https://images.example.com/look2.jpg"}} ] }] }'const out = await client.chat.completions.create({ model: "gpt-5", messages: [{ role: "user", content: [ { type: "text", text: "Are these outfits the same color palette? Explain differences." }, { type: "image_url", image_url: { url: "https://images.example.com/look1.jpg" } }, { type: "image_url", image_url: { url: "https://images.example.com/look2.jpg" } }, ] }]});console.log(out.choices[0].message.content[0].text);resp = client.chat.completions.create( model="gpt-5", messages=[{ "role": "user", "content": [ {"type": "text", "text": "Are these outfits the same color palette? Explain differences."}, {"type": "image_url", "image_url": {"url": "https://images.example.com/look1.jpg"}}, {"type": "image_url", "image_url": {"url": "https://images.example.com/look2.jpg"}}, ] }])print(resp.choices[0].message.content[0].text)package main
import ( "context" "fmt" "os"
openai "github.com/openai/openai-go" "github.com/openai/openai-go/option")
func main() { client := openai.NewClient( option.WithAPIKey(os.Getenv("AI_FOUNDRY_HUB_API_KEY")), option.WithBaseURL("https://api.aifoundryhub.com/v1"), )
ctx := context.Background() params := openai.ChatCompletionNewParams{ Model: "gpt-5", Messages: []openai.ChatCompletionMessageParamUnion{{ OfUser: &openai.ChatCompletionUserMessageParam{ Content: openai.ChatCompletionUserMessageParamContentUnion{ OfArrayOfContentParts: []openai.ChatCompletionContentPartUnionParam{ {OfText: &openai.ChatCompletionContentPartTextParam{Type: "text", Text: "Are these outfits the same color palette? Explain differences."}}, {OfImageURL: &openai.ChatCompletionContentPartImageParam{Type: "image_url", ImageURL: openai.ChatCompletionContentPartImageImageURLParam{URL: "https://images.example.com/look1.jpg"}}}, {OfImageURL: &openai.ChatCompletionContentPartImageParam{Type: "image_url", ImageURL: openai.ChatCompletionContentPartImageImageURLParam{URL: "https://images.example.com/look2.jpg"}}}, }, }, }, }}, } resp, err := client.Chat.Completions.New(ctx, params) if err != nil { panic(err) } if len(resp.Choices) > 0 && len(resp.Choices[0].Message.Content) > 0 { fmt.Println(resp.Choices[0].Message.Content[0]) }}Local images (base64 Data URL)
Section titled “Local images (base64 Data URL)”If you cannot host the image, send a Data URL as the image_url.url.
import fs from "node:fs";const b64 = fs.readFileSync("./chart.png", "base64");const dataUrl = `data:image/png;base64,${b64}`;
const out = await client.chat.completions.create({ model: "gpt-5", messages: [{ role: "user", content: [ { type: "text", text: "Summarize the main trend in this chart." }, { type: "image_url", image_url: { url: dataUrl, detail: "auto" } }, ] }], max_tokens: 200,});import base64b64 = base64.b64encode(open("chart.png", "rb").read()).decode("utf-8")
data_url = f"data:image/png;base64,{b64}"
out = client.chat.completions.create( model="gpt-5", messages=[{ "role": "user", "content": [ {"type": "text", "text": "Summarize the main trend in this chart."}, {"type": "image_url", "image_url": {"url": data_url, "detail": "auto"}}, ] }], max_tokens=200,)# Linux (GNU base64). On macOS use: b64=$(base64 chart.png | tr -d '\n')b64=$(base64 -w 0 chart.png)
curl -X POST "https://api.aifoundryhub.com/v1/chat/completions" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"model\": \"gpt-5\", \"max_tokens\": 200, \"messages\": [{ \"role\": \"user\", \"content\": [ {\"type\": \"text\", \"text\": \"Summarize the main trend in this chart.\"}, {\"type\": \"image_url\", \"image_url\": {\"url\": \"data:image/png;base64,$b64\", \"detail\": \"auto\"}} ] }] }"package main
import ( "context" "encoding/base64" "fmt" "os"
openai "github.com/openai/openai-go" "github.com/openai/openai-go/option")
func main() { // Read and base64-encode the local file img, err := os.ReadFile("chart.png") if err != nil { panic(err) } b64 := base64.StdEncoding.EncodeToString(img) dataURL := "data:image/png;base64," + b64
client := openai.NewClient( option.WithAPIKey(os.Getenv("AI_FOUNDRY_HUB_API_KEY")), option.WithBaseURL("https://api.aifoundryhub.com/v1"), )
ctx := context.Background() params := openai.ChatCompletionNewParams{ Model: "gpt-5", Messages: []openai.ChatCompletionMessageParamUnion{{ OfUser: &openai.ChatCompletionUserMessageParam{ Content: openai.ChatCompletionUserMessageParamContentUnion{ OfArrayOfContentParts: []openai.ChatCompletionContentPartUnionParam{ {OfText: &openai.ChatCompletionContentPartTextParam{Type: "text", Text: "Summarize the main trend in this chart."}}, {OfImageURL: &openai.ChatCompletionContentPartImageParam{Type: "image_url", ImageURL: openai.ChatCompletionContentPartImageImageURLParam{URL: dataURL}}}, }, }, }, }}, }
resp, err := client.Chat.Completions.New(ctx, params) if err != nil { panic(err) } if len(resp.Choices) > 0 && len(resp.Choices[0].Message.Content) > 0 { fmt.Println(resp.Choices[0].Message.Content[0]) }}Message content parts (vision)
Section titled “Message content parts (vision)”Returns
Section titled “Returns”A chat.completion object.
The same return shape as regular chat completions. Use
message.content[0].textto read the model’s textual answer.