PageSourceSearch

https://java2ai.com/assets/js/df02ce75.3b046197.js

js java2ai.com collected 2026-10-03 21:35:30 UTC 35,345 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkspring_ai_alibaba_website=self.webpackChunkspring_ai_alibaba_website||[]).push([[4691],{28453:(e,n,i)=>{i.d(n,{R:()=>o,x:()=>a});var r=i(96540);const s={},d=r.createContext(s);function o(e){const n=r.useContext(d);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),r.createElement(d.Provider,{value:n},e.children)}},93309:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>p,frontMatter:()=>o,metadata:()=>r,toc:()=>t});const r=JSON.parse('{"id":"multimodals/image/openai-sdk-image","title":"OpenAI SDK Image Generation (Official)","description":"Spring AI \u901a\u8fc7 OpenAI Java SDK \u652f\u6301 OpenAI \u7684 DALL-E \u56fe\u50cf\u751f\u6210\u6a21\u578b\uff0c\u63d0\u4f9b\u4e0e OpenAI \u670d\u52a1\uff08\u5305\u62ec Microsoft Foundry \u548c GitHub Models\uff09\u7684\u5f3a\u5927\u4e14\u5b98\u65b9\u7ef4\u62a4\u7684\u96c6\u6210\u3002","source":"@site/integration/multimodals/image/openai-sdk-image.md","sourceDirName":"multimodals/image","slug":"/multimodals/image/openai-sdk-image","permalink":"/integration/multimodals/image/openai-sdk-image","draft":false,"unlisted":false,"editUrl":"https://github.com/spring-ai-alibaba/website/tree/main/integration/multimodals/image/openai-sdk-image.md","tags":[],"version":"current","lastUpdatedBy":"txuw","lastUpdatedAt":1768049689000,"frontMatter":{},"sidebar":"integrationSidebar","previous":{"title":"OpenAI Image Generation","permalink":"/integration/multimodals/image/openai-image"},"next":{"title":"QianFan Image","permalink":"/integration/multimodals/image/qianfan-image"}}');var s=i(74848),d=i(28453);const o={},a="OpenAI SDK Image Generation (Official)",l={},t=[{value:"Authentication",id:"authentication",level:2},{value:"Using OpenAI",id:"using-openai",level:3},{value:"Using Microsoft Foundry",id:"using-microsoft-foundry",level:3},{value:"Using GitHub Models",id:"using-github-models",level:3},{value:"Add Repositories and BOM",id:"add-repositories-and-bom",level:3},{value:"Auto-configuration",id:"auto-configuration",level:2},{value:"Configuration Properties",id:"configuration-properties",level:3},{value:"Connection Properties",id:"connection-properties",level:4},{value:"Microsoft Foundry Properties",id:"microsoft-foundry-properties",level:4},{value:"GitHub Models Properties",id:"github-models-properties",level:4},{value:"Image Model Properties",id:"image-model-properties",level:4},{value:"Runtime Options",id:"runtime-options",level:2},{value:"Sample Controller",id:"sample-controller",level:2},{value:"Manual Configuration",id:"manual-configuration",level:2},{value:"Microsoft Foundry Configuration",id:"microsoft-foundry-configuration",level:3},{value:"GitHub Models Configuration",id:"github-models-configuration",level:3},{value:"Observability",id:"observability",level:2},{value:"Additional Resources",id:"additional-resources",level:2}];function c(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"openai-sdk-image-generation-official",children:"OpenAI SDK Image Generation (Official)"})}),"\n",(0,s.jsx)(n.p,{children:"Spring AI \u901a\u8fc7 OpenAI Java SDK \u652f\u6301 OpenAI \u7684 DALL-E \u56fe\u50cf\u751f\u6210\u6a21\u578b\uff0c\u63d0\u4f9b\u4e0e OpenAI \u670d\u52a1\uff08\u5305\u62ec Microsoft Foundry \u548c GitHub Models\uff09\u7684\u5f3a\u5927\u4e14\u5b98\u65b9\u7ef4\u62a4\u7684\u96c6\u6210\u3002"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"NOTE"}),": \u6b64\u5b9e\u73b0\u4f7f\u7528\u6765\u81ea OpenAI \u7684\u5b98\u65b9 ",(0,s.jsx)(n.a,{href:"https://github.com/openai/openai-java",children:"OpenAI Java SDK"}),"\u3002\u6709\u5173\u66ff\u4ee3\u7684 Spring AI \u5b9e\u73b0\uff0c\u8bf7\u53c2\u9605 ",(0,s.jsx)(n.a,{href:"/integration/multimodals/image/openai-image",children:"OpenAI Image Generation"}),"\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"DALL-E \u662f\u6765\u81ea OpenAI \u7684\u6700\u5148\u8fdb\u7684\u56fe\u50cf\u751f\u6210\u6a21\u578b\uff0c\u53ef\u4ee5\u4ece\u81ea\u7136\u8bed\u8a00\u63cf\u8ff0\u521b\u5efa\u903c\u771f\u7684\u56fe\u50cf\u548c\u827a\u672f\u4f5c\u54c1\u3002"}),"\n",(0,s.jsx)(n.p,{children:"OpenAI SDK \u6a21\u5757\u6839\u636e\u60a8\u63d0\u4f9b\u7684\u57fa\u7840 URL \u81ea\u52a8\u68c0\u6d4b\u670d\u52a1\u63d0\u4f9b\u8005\uff08OpenAI\u3001Microsoft Foundry \u6216 GitHub Models\uff09\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"authentication",children:"Authentication"}),"\n",(0,s.jsx)(n.p,{children:"\u4f7f\u7528\u57fa\u7840 URL \u548c API Key \u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002\u8be5\u5b9e\u73b0\u901a\u8fc7 Spring Boot \u5c5e\u6027\u6216\u73af\u5883\u53d8\u91cf\u63d0\u4f9b\u7075\u6d3b\u7684\u914d\u7f6e\u9009\u9879\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"using-openai",children:"Using OpenAI"}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u76f4\u63a5\u4f7f\u7528 OpenAI\uff0c\u8bf7\u5728 ",(0,s.jsx)(n.a,{href:"https://platform.openai.com/signup",children:"OpenAI signup page"})," \u521b\u5efa\u8d26\u6237\uff0c\u5e76\u5728 ",(0,s.jsx)(n.a,{href:"https://platform.openai.com/account/api-keys",children:"API Keys page"})," \u751f\u6210 API key\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u57fa\u7840 URL \u4e0d\u9700\u8981\u8bbe\u7f6e\uff0c\u56e0\u4e3a\u5b83\u9ed8\u8ba4\u4e3a ",(0,s.jsx)(n.code,{children:"https://api.openai.com/v1"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"spring.ai.openai-sdk.api-key=<your-openai-api-key>
1\n# base-url is optional, defaults to https://api.openai.com/v1\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6216\u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"export OPENAI_API_KEY=<your-openai-api-key>\n# OPENAI_BASE_URL is optional, defaults to https://api.openai.com/v1\n"})}),"\n",(0,s.jsx)(n.h3,{id:"using-microsoft-foundry",children:"Using Microsoft Foundry"}),"\n",(0,s.jsx)(n.p,{children:"\u5f53\u4f7f\u7528 Microsoft Foundry URL \u65f6\uff0cMicrosoft Foundry \u4f1a\u81ea\u52a8\u68c0\u6d4b\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u5c5e\u6027\u914d\u7f6e\u5b83\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"spring.ai.openai-sdk.base-url=https://<your-deployment-url>.openai.azure.com\nspring.ai.openai-sdk.api-key=<your-api-key>\nspring.ai.openai-sdk.microsoft-deployment-name=<your-deployment-name>\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6216\u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"export OPENAI_BASE_URL=https://<your-deployment-url>.openai.azure.com\nexport OPENAI_API_KEY=<your-api-key>\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Passwordless Authentication (Recommended for Azure):"})}),"\n",(0,s.jsx)(n.p,{children:"Microsoft Foundry \u652f\u6301\u65e0\u5bc6\u7801\u8eab\u4efd\u9a8c\u8bc1\uff0c\u65e0\u9700\u63d0\u4f9b API key\uff0c\u5728 Azure \u4e0a\u8fd0\u884c\u65f6\u66f4\u5b89\u5168\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u8981\u542f\u7528\u65e0\u5bc6\u7801\u8eab\u4efd\u9a8c\u8bc1\uff0c\u8bf7\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"com.azure:azure-identity"})," \u4f9d\u8d56\u9879\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",children:"<dependency>\n    <groupId>com.azure</groupId>\n    <artifactId>azure-identity</artifactId>\n</dependency>\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u7136\u540e\u914d\u7f6e\u65f6\u4e0d\u4f7f\u7528 API key\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"spring.ai.openai-sdk.base-url=https://<your-deployment-url>.openai.azure.com\nspring.ai.openai-sdk.microsoft-deployment-name=<your-deployment-name>\n# No api-key needed - will use Azure credentials from environment\n"})}),"\n",(0,s.jsx)(n.h3,{id:"using-github-models",children:"Using GitHub Models"}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u4f7f\u7528 GitHub Models \u57fa\u7840 URL \u65f6\uff0cGitHub Models \u4f1a\u81ea\u52a8\u68c0\u6d4b\u3002\u60a8\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u5177\u6709 ",(0,s.jsx)(n.code,{children:"models:read"})," \u8303\u56f4\u7684 GitHub Personal Access Token (PAT)\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"spring.ai.openai-sdk.base-url=https://models.inference.ai.azure.com\nspring.ai.openai-sdk.api-key=github_pat_XXXXXXXXXXX\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6216\u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"export OPENAI_BASE_URL=https://models.inference.ai.azure.com\nexport OPENAI_API_KEY=github_pat_XXXXXXXXXXX\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": \u4e3a\u4e86\u5728\u5904\u7406\u654f\u611f\u4fe1\u606f\uff08\u5982 API keys\uff09\u65f6\u589e\u5f3a\u5b89\u5168\u6027\uff0c\u60a8\u53ef\u4ee5\u5728\u5c5e\u6027\u4e2d\u4f7f\u7528 Spring Expression Language (SpEL)\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"spring.ai.openai-sdk.api-key=${OPENAI_API_KEY}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"add-repositories-and-bom",children:"Add Repositories and BOM"}),"\n",(0,s.jsxs)(n.p,{children:["Spring AI artifacts \u53d1\u5e03\u5728 Maven Central \u548c Spring Snapshot \u5b58\u50a8\u5e93\u4e2d\u3002\n\u8bf7\u53c2\u8003 ",(0,s.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#artifact-repositories",children:"Artifact Repositories"})," \u90e8\u5206\uff0c\u5c06\u8fd9\u4e9b\u5b58\u50a8\u5e93\u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u7cfb\u7edf\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u5e2e\u52a9\u4f9d\u8d56\u7ba1\u7406\uff0cSpring AI \u63d0\u4f9b\u4e86\u4e00\u4e2a BOM\uff08\u7269\u6599\u6e05\u5355\uff09\u4ee5\u786e\u4fdd\u5728\u6574\u4e2a\u9879\u76ee\u4e2d\u4f7f\u7528\u4e00\u81f4\u7248\u672c\u7684 Spring AI\u3002\u8bf7\u53c2\u8003 ",(0,s.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u7cfb\u7edf\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"auto-configuration",children:"Auto-configuration"}),"\n",(0,s.jsxs)(n.p,{children:["Spring AI \u4e3a OpenAI SDK Image Model \u63d0\u4f9b Spring Boot \u81ea\u52a8\u914d\u7f6e\u3002\n\u8981\u542f\u7528\u5b83\uff0c\u8bf7\u5c06\u4ee5\u4e0b\u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u9879\u76ee\u7684 Maven ",(0,s.jsx)(n.code,{children:"pom.xml"})," \u6216 Gradle ",(0,s.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u4e2d\uff1a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Maven:"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",children:"<dependency>\n    <groupId>org.springframework.ai</groupId>\n    <artifactId>spring-ai-starter-model-openai-sdk</artifactId>\n</dependency>\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Gradle:"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n    implementation 'org.springframework.ai:spring-ai-starter-model-openai-sdk'\n}\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": \u8bf7\u53c2\u8003 ",(0,s.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u4e2d\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"configuration-properties",children:"Configuration Properties"}),"\n",(0,s.jsx)(n.h4,{id:"connection-properties",children:"Connection Properties"}),"\n",(0,s.jsxs)(n.p,{children:["\u524d\u7f00 ",(0,s.jsx)(n.code,{children:"spring.ai.openai-sdk"})," \u7528\u4f5c\u5141\u8bb8\u60a8\u914d\u7f6e OpenAI SDK \u5ba2\u6237\u7aef\u7684\u5c5e\u6027\u524d\u7f00\u3002"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Property"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.base-url"}
1),(0,s.jsxs)(n.td,{children:["\u8fde\u63a5\u7684 URL\u3002\u5982\u679c\u672a\u8bbe\u7f6e\uff0c\u5219\u4ece ",(0,s.jsx)(n.code,{children:"OPENAI_BASE_URL"})," \u73af\u5883\u53d8\u91cf\u81ea\u52a8\u68c0\u6d4b"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"https://api.openai.com/v1",children:"https://api.openai.com/v1"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.api-key"}),(0,s.jsxs)(n.td,{children:["API Key\u3002\u5982\u679c\u672a\u8bbe\u7f6e\uff0c\u5219\u4ece ",(0,s.jsx)(n.code,{children:"OPENAI_API_KEY"})," \u73af\u5883\u53d8\u91cf\u81ea\u52a8\u68c0\u6d4b"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.organization-id"}),(0,s.jsx)(n.td,{children:"\u53ef\u9009\uff0c\u6307\u5b9a\u7528\u4e8e API \u8bf7\u6c42\u7684\u7ec4\u7ec7"}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.timeout"}),(0,s.jsx)(n.td,{children:"\u8bf7\u6c42\u8d85\u65f6\u6301\u7eed\u65f6\u95f4"}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.max-retries"}),(0,s.jsx)(n.td,{children:"\u5931\u8d25\u8bf7\u6c42\u7684\u6700\u5927\u91cd\u8bd5\u5c1d\u8bd5\u6b21\u6570"}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.proxy"}),(0,s.jsxs)(n.td,{children:["OpenAI \u5ba2\u6237\u7aef\u7684\u4ee3\u7406\u8bbe\u7f6e\uff08Java ",(0,s.jsx)(n.code,{children:"Proxy"})," \u5bf9\u8c61\uff09"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.custom-headers"}),(0,s.jsx)(n.td,{children:"\u8981\u5728\u8bf7\u6c42\u4e2d\u5305\u542b\u7684\u81ea\u5b9a\u4e49 HTTP \u6807\u5934\u3002\u6807\u5934\u540d\u79f0\u5230\u6807\u5934\u503c\u7684\u6620\u5c04"}),(0,s.jsx)(n.td,{children:"-"})]})]})]}),"\n",(0,s.jsx)(n.h4,{id:"microsoft-foundry-properties",children:"Microsoft Foundry Properties"}),"\n",(0,s.jsx)(n.p,{children:"OpenAI SDK \u5b9e\u73b0\u4e3a Microsoft Foundry \u63d0\u4f9b\u539f\u751f\u652f\u6301\uff0c\u5177\u6709\u81ea\u52a8\u914d\u7f6e\uff1a"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Property"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.microsoft-foundry"}),(0,s.jsxs)(n.td,{children:["\u542f\u7528 Microsoft Foundry \u6a21\u5f0f\u3002\u5982\u679c\u57fa\u7840 URL \u5305\u542b ",(0,s.jsx)(n.code,{children:"openai.azure.com"}),"\u3001",(0,s.jsx)(n.code,{children:"cognitiveservices.azure.com"})," \u6216 ",(0,s.jsx)(n.code,{children:".openai.microsoftFoundry.com"}),"\uff0c\u5219\u81ea\u52a8\u68c0\u6d4b"]}),(0,s.jsx)(n.td,{children:"false"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.microsoft-deployment-name"}),(0,s.jsxs)(n.td,{children:["Microsoft Foundry \u90e8\u7f72\u540d\u79f0\u3002\u5982\u679c\u672a\u6307\u5b9a\uff0c\u5c06\u4f7f\u7528\u6a21\u578b\u540d\u79f0\u3002\u4e5f\u53ef\u901a\u8fc7\u522b\u540d ",(0,s.jsx)(n.code,{children:"deployment-name"})," \u8bbf\u95ee"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.microsoft-foundry-service-version"}),(0,s.jsx)(n.td,{children:"Microsoft Foundry API \u670d\u52a1\u7248\u672c"}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.credential"}),(0,s.jsxs)(n.td,{children:["\u7528\u4e8e\u65e0\u5bc6\u7801\u8eab\u4efd\u9a8c\u8bc1\u7684\u51ed\u636e\u5bf9\u8c61\uff08\u9700\u8981 ",(0,s.jsx)(n.code,{children:"com.azure:azure-identity"})," \u4f9d\u8d56\u9879\uff09"]}),(0,s.jsx)(n.td,{children:"-"})]})]})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": Microsoft Foundry \u652f\u6301\u65e0\u5bc6\u7801\u8eab\u4efd\u9a8c\u8bc1\u3002\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"com.azure:azure-identity"})," \u4f9d\u8d56\u9879\uff0c\u5f53\u672a\u63d0\u4f9b API key \u65f6\uff0c\u5b9e\u73b0\u5c06\u81ea\u52a8\u5c1d\u8bd5\u4f7f\u7528\u73af\u5883\u4e2d\u7684 Azure \u51ed\u636e\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h4,{id:"github-models-properties",children:"GitHub Models Properties"}),"\n",(0,s.jsx)(n.p,{children:"\u63d0\u4f9b\u5bf9 GitHub Models \u7684\u539f\u751f\u652f\u6301\uff1a"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Property"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.github-models"}),(0,s.jsxs)(n.td,{children:["\u542f\u7528 GitHub Models \u6a21\u5f0f\u3002\u5982\u679c\u57fa\u7840 URL \u5305\u542b ",(0,s.jsx)(n.code,{children:"models.github.ai"})," \u6216 ",(0,s.jsx)(n.code,{children:"models.inference.ai.azure.com"}),"\uff0c\u5219\u81ea\u52a8\u68c0\u6d4b"]}),(0,s.jsx)(n.td,{children:"false"})]})})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": GitHub Models \u9700\u8981\u5177\u6709 ",(0,s.jsx)(n.code,{children:"models:read"})," \u8303\u56f4\u7684 Personal Access Token\u3002\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"OPENAI_API_KEY"})," \u73af\u5883\u53d8\u91cf\u6216 ",(0,s.jsx)(n.code,{children:"spring.ai.openai-sdk.api-key"})," \u5c5e\u6027\u8bbe\u7f6e\u5b83\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h4,{id:"image-model-properties",children:"Image Model Properties"}),"\n",(0,s.jsxs)(n.p,{children:["\u524d\u7f00 ",(0,s.jsx)(n.code,{children:"spring.ai.openai-sdk.image"})," \u662f\u7528\u4e8e\u914d\u7f6e\u56fe\u50cf\u6a21\u578b\u5b9e\u73b0\u7684\u5c5e\u6027\u524d\u7f00\uff1a"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Property"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Default"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.model"}),(0,s.jsxs)(n.td,{children:["\u7528\u4e8e\u56fe\u50cf\u751f\u6210\u7684\u6a21\u578b\u3002\u53ef\u7528\u6a21\u578b\uff1a",(0,s.jsx)(n.code,{children:"dall-e-2"}),"\u3001",(0,s.jsx)(n.code,{children:"dall-e-3"}),"\u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 ",(0,s.jsx)(n.a,{href:"https://platform.openai.com/docs/models",children:"models"})," \u9875\u9762"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"dall-e-3"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.n"}),(0,s.jsxs)(n.td,{children:["\u8981\u751f\u6210\u7684\u56fe\u50cf\u6570\u91cf\u3002\u5fc5\u987b\u5728 1 \u5230 10 \u4e4b\u95f4\u3002\u5bf9\u4e8e ",(0,s.jsx)(n.code,{children:"dall-e-3"}),"\uff0c\u4ec5\u652f\u6301 n=1"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.quality"}),(0,s.jsxs)(n.td,{children:["\u5c06\u751f\u6210\u7684\u56fe\u50cf\u8d28\u91cf\u3002",(0,s.jsx)(n.code,{children:"hd"})," \u521b\u5efa\u5177\u6709\u66f4\u7cbe\u7ec6\u7ec6\u8282\u548c\u66f4\u5927\u4e00\u81f4\u6027\u7684\u56fe\u50cf\u3002\u6b64\u53c2\u6570\u4ec5\u652f\u6301 ",(0,s.jsx)(n.code,{children:"dall-e-3"}),"\u3002\u53ef\u7528\u503c\uff1a",(0,s.jsx)(n.code,{children:"standard"}),"\u3001",(0,s.jsx)(n.code,{children:"hd"})]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.response-format"}),(0,s.jsxs)(n.td,{children:["\u8fd4\u56de\u751f\u6210\u7684\u56fe\u50cf\u7684\u683c\u5f0f\u3002\u5fc5\u987b\u662f ",(0,s.jsx)(n.code,{children:"url"})," \u6216 ",(0,s.jsx)(n.code,{children:"b64_json"})," \u4e4b\u4e00"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.size"}),(0,s.jsxs)(n.td,{children:["\u751f\u6210\u7684\u56fe\u50cf\u5927\u5c0f\u3002\u5bf9\u4e8e ",(0,s.jsx)(n.code,{children:"dall-e-2"}),"\uff0c\u5fc5\u987b\u662f ",(0,s.jsx)(n.code,{children:"256x256"}),"\u3001",(0,s.jsx)(n.code,{children:"512x512"})," \u6216 ",(0,s.jsx)(n.code,{children:"1024x1024"})," \u4e4b\u4e00\u3002\u5bf9\u4e8e ",(0,s.jsx)(n.code,{children:"dall-e-3"})," \u6a21\u578b\uff0c\u5fc5\u987b\u662f ",(0,s.jsx)(n.code,{children:"1024x1024"}),"\u3001",(0,s.jsx)(n.code,{children:"1792x1024"})," \u6216 ",(0,s.jsx)(n.code,{children:"1024x1792"})," \u4e4b\u4e00"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.width"}),(0,s.jsxs)(n.td,{children:["\u751f\u6210\u7684\u56fe\u50cf\u5bbd\u5ea6\u3002\u5bf9\u4e8e ",(0,s.jsx)(n.code,{children:"dall-e-2"}),"\uff0c\u5fc5\u987b\u662f 256\u3001512 \u6216 1024 \u4e4b\u4e00"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.height"}),(0,s.jsxs)(n.td,{children:["\u751f\u6210\u7684\u56fe\u50cf\u9ad8\u5ea6\u3002\u5bf9\u4e8e ",(0,s.jsx)(n.code,{children:"dall-e-2"}),"\uff0c\u5fc5\u987b\u662f 256\u3001512 \u6216 1024 \u4e4b\u4e00"]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.style"}),(0,s.jsxs)(n.td,{children:["\u751f\u6210\u7684\u56fe\u50cf\u6837\u5f0f\u3002\u5fc5\u987b\u662f ",(0,s.jsx)(n.code,{children:"vivid"})," \u6216 ",(0,s.jsx)(n.code,{children:"natural"})," \u4e4b\u4e00\u3002Vivid \u4f7f\u6a21\u578b\u503e\u5411\u4e8e\u751f\u6210\u8d85\u771f\u5b9e\u548c\u620f\u5267\u6027\u7684\u56fe\u50cf\u3002Natural \u4f7f\u6a21\u578b\u4ea7\u751f\u66f4\u81ea\u7136\u3001\u4e0d\u90a3\u4e48\u8d85\u771f\u5b9e\u7684\u56fe\u50cf\u3002\u6b64\u53c2\u6570\u4ec5\u652f\u6301 ",(0,s.jsx)(n.code,{children:"dall-e-3"})]}),(0,s.jsx)(n.td,{children:"-"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"spring.ai.openai-sdk.image.options.user"}),(0,s.jsx)(n.td,{children:"\u4ee3\u8868\u60a8\u7684\u6700\u7ec8\u7528\u6237\u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u53ef\u4ee5\u5e2e\u52a9 OpenAI \u76d1\u63a7\u548c\u68c0\u6d4b\u6ee5\u7528"}),(0,s.jsx)(n.td,{children:"-"})]})]})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": \u6240\u6709\u4ee5 ",(0,s.jsx)(n.code,{children:"spring.ai.openai-sdk.image.options"})," \u4e3a\u524d\u7f00\u7684\u5c5e\u6027\u90fd\u53ef\u4ee5\u901a\u8fc7\u5728 ",(0,s.jsx)(n.code,{children:"ImagePrompt"})," \u8c03\u7528\u4e2d\u6dfb\u52a0\u7279\u5b9a\u4e8e\u8bf7\u6c42\u7684 ",(0,s.jsx)(n.a,{href:"#runtime-options",children:"image-options"})," \u5728\u8fd0\u884c\u65f6\u8986\u76d6\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"runtime-options",children:"Runtime Options"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-openai-sdk/src/main/java/org/springframework/ai/openaisdk/OpenAiSdkImageOptions.java",children:"OpenAiSdkImageOptions.java"})," \u63d0\u4f9b OpenAI \u914d\u7f6e\uff0c\u4f8b\u5982\u8981\u4f7f\u7528\u7684\u6a21\u578b\u3001\u8d28\u91cf\u3001\u5927\u5c0f\u3001\u6837\u5f0f\u548c\u8981\u751f\u6210\u7684\u56fe\u50cf\u6570\u91cf\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e5f\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"spring.ai.openai-sdk.image.options"})," \u5c5e\u6027\u914d\u7f6e\u9ed8\u8ba4\u9009\u9879\u3002"]}
1),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u542f\u52a8\u65f6\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"OpenAiSdkImageModel"})," \u6784\u9020\u51fd\u6570\u8bbe\u7f6e\u7528\u4e8e\u6240\u6709\u56fe\u50cf\u751f\u6210\u8bf7\u6c42\u7684\u9ed8\u8ba4\u9009\u9879\u3002\n\u5728\u8fd0\u884c\u65f6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"OpenAiSdkImageOptions"})," \u5b9e\u4f8b\u4f5c\u4e3a ",(0,s.jsx)(n.code,{children:"ImagePrompt"})," \u7684\u4e00\u90e8\u5206\u6765\u8986\u76d6\u9ed8\u8ba4\u9009\u9879\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u4e3a\u7279\u5b9a\u8bf7\u6c42\u8986\u76d6\u9ed8\u8ba4\u6a21\u578b\u548c\u8d28\u91cf\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'ImageResponse response = imageModel.call(\n    new ImagePrompt("A light cream colored mini golden doodle",\n        OpenAiSdkImageOptions.builder()\n            .model("dall-e-3")\n            .quality("hd")\n            .N(1)\n            .width(1024)\n            .height(1024)\n            .style("vivid")\n        .build()));\n'})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": \u9664\u4e86\u6a21\u578b\u7279\u5b9a\u7684 ",(0,s.jsx)(n.a,{href:"https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-openai-sdk/src/main/java/org/springframework/ai/openaisdk/OpenAiSdkImageOptions.java",children:"OpenAiSdkImageOptions"}),"\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u53ef\u79fb\u690d\u7684 ",(0,s.jsx)(n.a,{href:"https://github.com/spring-projects/spring-ai/blob/main/spring-ai-model/src/main/java/org/springframework/ai/image/ImageOptions.java",children:"ImageOptions"})," \u5b9e\u4f8b\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.a,{href:"https://github.com/spring-projects/spring-ai/blob/main/spring-ai-model/src/main/java/org/springframework/ai/image/ImageOptionsBuilder.java",children:"ImageOptionsBuilder#builder()"})," \u521b\u5efa\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"sample-controller",children:"Sample Controller"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://start.spring.io/",children:"Create"})," \u4e00\u4e2a\u65b0\u7684 Spring Boot \u9879\u76ee\uff0c\u5e76\u5c06 ",(0,s.jsx)(n.code,{children:"spring-ai-openai-sdk"})," \u6dfb\u52a0\u5230\u60a8\u7684 pom\uff08\u6216 gradle\uff09\u4f9d\u8d56\u9879\u4e2d\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"src/main/resources"})," \u76ee\u5f55\u4e0b\u6dfb\u52a0\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"application.properties"})," \u6587\u4ef6\u6765\u914d\u7f6e OpenAI SDK \u56fe\u50cf\u6a21\u578b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-properties",children:"spring.ai.openai-sdk.api-key=YOUR_API_KEY\nspring.ai.openai-sdk.image.options.model=dall-e-3\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": \u5c06 ",(0,s.jsx)(n.code,{children:"api-key"})," \u66ff\u6362\u4e3a\u60a8\u7684 OpenAI \u51ed\u636e\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"OpenAiSdkImageModel"})," \u5b9e\u73b0\uff0c\u60a8\u53ef\u4ee5\u5c06\u5176\u6ce8\u5165\u5230\u60a8\u7684\u7c7b\u4e2d\u3002\n\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528\u56fe\u50cf\u6a21\u578b\u7684\u7b80\u5355 ",(0,s.jsx)(n.code,{children:"@RestController"})," \u7c7b\u793a\u4f8b\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'@RestController\npublic class ImageController {\n\n    private final ImageModel imageModel;\n\n    @Autowired\n    public ImageController(ImageModel imageModel) {\n        this.imageModel = imageModel;\n    }\n\n    @GetMapping("/ai/image")\n    public Map<String, Object> generateImage(\n            @RequestParam(value = "prompt", defaultValue = "A light cream colored mini golden doodle") String prompt) {\n        ImageResponse response = this.imageModel.call(\n            new ImagePrompt(prompt,\n                OpenAiSdkImageOptions.builder()\n                    .quality("hd")\n                    .N(1)\n                    .width(1024)\n                    .height(1024)\n                .build()));\n        \n        String imageUrl = response.getResult().getOutput().getUrl();\n        return Map.of("url", imageUrl);\n    }\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"manual-configuration",children:"Manual Configuration"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-openai-sdk/src/main/java/org/springframework/ai/openaisdk/OpenAiSdkImageModel.java",children:"OpenAiSdkImageModel"})," \u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"ImageModel"}
1)," \u5e76\u4f7f\u7528\u5b98\u65b9 OpenAI Java SDK \u8fde\u63a5\u5230 OpenAI \u670d\u52a1\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u4e0d\u4f7f\u7528 Spring Boot \u81ea\u52a8\u914d\u7f6e\uff0c\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e OpenAI SDK Image Model\u3002\n\u4e3a\u6b64\uff0c\u8bf7\u5c06 ",(0,s.jsx)(n.code,{children:"spring-ai-openai-sdk"})," \u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u9879\u76ee\u7684 Maven ",(0,s.jsx)(n.code,{children:"pom.xml"})," \u6587\u4ef6\u4e2d\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",children:"<dependency>\n    <groupId>org.springframework.ai</groupId>\n    <artifactId>spring-ai-openai-sdk</artifactId>\n</dependency>\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6216\u6dfb\u52a0\u5230 Gradle ",(0,s.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u4e2d\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n    implementation 'org.springframework.ai:spring-ai-openai-sdk'\n}\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": \u8bf7\u53c2\u8003 ",(0,s.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u4e2d\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"NOTE"}),": ",(0,s.jsx)(n.code,{children:"spring-ai-openai-sdk"})," \u4f9d\u8d56\u9879\u8fd8\u63d0\u4f9b\u5bf9 ",(0,s.jsx)(n.code,{children:"OpenAiSdkChatModel"})," \u548c ",(0,s.jsx)(n.code,{children:"OpenAiSdkEmbeddingModel"})," \u7684\u8bbf\u95ee\u3002\n\u6709\u5173 ",(0,s.jsx)(n.code,{children:"OpenAiSdkChatModel"})," \u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 ",(0,s.jsx)(n.a,{href:"/integration/chatmodels/more/openai-sdk-chat",children:"OpenAI SDK Chat"})," \u90e8\u5206\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\uff0c\u521b\u5efa\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"OpenAiSdkImageModel"})," \u5b9e\u4f8b\u5e76\u4f7f\u7528\u5b83\u751f\u6210\u56fe\u50cf\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'var imageOptions = OpenAiSdkImageOptions.builder()\n    .model("dall-e-3")\n    .quality("hd")\n    .apiKey(System.getenv("OPENAI_API_KEY"))\n    .build();\n\nvar imageModel = new OpenAiSdkImageModel(imageOptions);\n\nImageResponse response = imageModel.call(\n    new ImagePrompt("A light cream colored mini golden doodle",\n        OpenAiSdkImageOptions.builder()\n            .N(1)\n            .width(1024)\n            .height(1024)\n        .build()));\n'})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"OpenAiSdkImageOptions"})," \u63d0\u4f9b\u56fe\u50cf\u751f\u6210\u8bf7\u6c42\u7684\u914d\u7f6e\u4fe1\u606f\u3002\n\u9009\u9879\u7c7b\u63d0\u4f9b\u4e86\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"builder()"})," \u7528\u4e8e\u8f7b\u677e\u521b\u5efa\u9009\u9879\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"microsoft-foundry-configuration",children:"Microsoft Foundry Configuration"}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u4e8e Microsoft Foundry\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'var imageOptions = OpenAiSdkImageOptions.builder()\n    .baseUrl("https://your-resource.openai.azure.com")\n    .apiKey(System.getenv("OPENAI_API_KEY"))\n    .deploymentName("dall-e-3")\n    .azureOpenAIServiceVersion(AzureOpenAIServiceVersion.V2024_10_01_PREVIEW)\n    .azure(true)  // Enables Microsoft Foundry mode\n    .build();\n\nvar imageModel = new OpenAiSdkImageModel(imageOptions);\n'})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"TIP"}),": Microsoft Foundry \u652f\u6301\u65e0\u5bc6\u7801\u8eab\u4efd\u9a8c\u8bc1\u3002\u5c06 ",(0,s.jsx)(n.code,{children:"com.azure:azure-identity"})," \u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u60a8\u7684\u9879\u76ee\u3002\u5982\u679c\u60a8\u4e0d\u63d0\u4f9b API key\uff0c\u5b9e\u73b0\u5c06\u81ea\u52a8\u5c1d\u8bd5\u4f7f\u7528\u73af\u5883\u4e2d\u7684 Azure \u51ed\u636e\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"github-models-configuration",children:"GitHub Models Configuration"}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u4e8e GitHub Models\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'var imageOptions = OpenAiSdkImageOptions.builder()\n    .baseUrl("https://models.inference.ai.azure.com")\n    .apiKey(System.getenv("GITHUB_TOKEN"))\n    .model("dall-e-3")\n    .githubModels(true)\n    .build();\n\nvar imageModel = new OpenAiSdkImageModel(imageOptions);\n'})}),"\n",(0,s.jsx)(n.h2,{id:"observability",children:"Observability"}),"\n",(0,s.jsx)(n.p,{children:"OpenAI SDK \u5b9e\u73b0\u901a\u8fc7 Micrometer \u652f\u6301 Spring AI \u7684\u53ef\u89c2\u6d4b\u6027\u529f\u80fd\u3002\n\u6240\u6709\u56fe\u50cf\u6a21\u578b\u64cd\u4f5c\u90fd\u7ecf\u8fc7\u68c0\u6d4b\u4ee5\u8fdb\u884c\u76d1\u63a7\u548c\u8ddf\u8e2a\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"additional-resources",children:"Additional Resources"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/openai/openai-java",children:"Official OpenAI Java SDK"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://platform.openai.com/docs/api-reference/images",children:"OpenAI Images API Documentation"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://platform.openai.com/docs/guides/images",children:"OpenAI Image Generation Guide"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://platform.openai.com/docs/models",children:"OpenAI Models"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://learn.microsoft.com/en-us
1/azure/ai-foundry/",children:"Microsoft Foundry Documentation"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/marketplace/models",children:"GitHub Models"})}),"\n"]})]})}function p(e={}){const{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.