Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target
.classpath
.project
.settings
.env
bin
build.log
integration-repo
Expand Down Expand Up @@ -55,4 +56,3 @@ tmp


plans

5 changes: 5 additions & 0 deletions models/spring-ai-openai-official/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OpenAI Java API Library

This is the official OpenAI Java SDK from OpenAI, which provides integration with OpenAI's services, including Azure OpenAI.

[OpenAI Java API Library GitHub repository](https://github.com/openai/openai-java)
95 changes: 95 additions & 0 deletions models/spring-ai-openai-official/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023-2025 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>spring-ai-openai-official</artifactId>
<packaging>jar</packaging>
<name>Spring AI Model - OpenAI Official</name>
<description>OpenAI Java API Library support</description>
<url>https://github.com/spring-projects/spring-ai</url>

<scm>
<url>https://github.com/spring-projects/spring-ai</url>
<connection>git://github.com/spring-projects/spring-ai.git</connection>
<developerConnection>git@github.com:spring-projects/spring-ai.git</developerConnection>
</scm>

<properties>
</properties>

<dependencies>

<!-- production dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-model</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>${openai-official.version}</version>
</dependency>

<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>${azure-identity.version}</version>
<optional>true</optional>
</dependency>

<!-- Spring Framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-observation-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.openaiofficial;

import com.openai.azure.AzureOpenAIServiceVersion;
import com.openai.credential.Credential;

import java.net.Proxy;
import java.time.Duration;
import java.util.Map;

public class AbstractOpenAiOfficialOptions {

/**
* The deployment URL to connect to OpenAI.
*/
private String baseUrl;

/**
* The API key to connect to OpenAI.
*/
private String apiKey;

/**
* Credentials used to connect to Azure OpenAI.
*/
private Credential credential;

/**
* The model name used. When using Azure AI Foundry, this is also used as the default
* deployment name.
*/
private String model;

/**
* The deployment name as defined in Azure AI Foundry. On Azure AI Foundry, the
* default deployment name is the same as the model name. When using OpenAI directly,
* this value isn't used.
*/
private String azureDeploymentName;

/**
* The Azure OpenAI Service version to use when connecting to Azure AI Foundry.
*/
private AzureOpenAIServiceVersion azureOpenAIServiceVersion;

/**
* The organization ID to use when connecting to Azure OpenAI.
*/
private String organizationId;

/**
* Whether Azure OpenAI is detected.
*/
private boolean isAzure;

/**
* Whether GitHub Models is detected.
*/
private boolean isGitHubModels;

/**
* Request timeout for OpenAI client.
*/
private Duration timeout;

/**
* Maximum number of retries for OpenAI client.
*/
private Integer maxRetries;

/**
* Proxy settings for OpenAI client.
*/
private Proxy proxy;

/**
* Custom headers to add to OpenAI client requests.
*/
private Map<String, String> customHeaders;

public String getBaseUrl() {
return baseUrl;
}

public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}

public String getApiKey() {
return apiKey;
}

public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}

public Credential getCredential() {
return credential;
}

public void setCredential(Credential credential) {
this.credential = credential;
}

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public String getAzureDeploymentName() {
return azureDeploymentName;
}

public void setAzureDeploymentName(String azureDeploymentName) {
this.azureDeploymentName = azureDeploymentName;
}

/**
* Alias for getAzureDeploymentName()
*/
public String getDeploymentName() {
return azureDeploymentName;
}

/**
* Alias for setAzureDeploymentName()
*/
public void setDeploymentName(String azureDeploymentName) {
this.azureDeploymentName = azureDeploymentName;
}

public AzureOpenAIServiceVersion getAzureOpenAIServiceVersion() {
return azureOpenAIServiceVersion;
}

public void setAzureOpenAIServiceVersion(AzureOpenAIServiceVersion azureOpenAIServiceVersion) {
this.azureOpenAIServiceVersion = azureOpenAIServiceVersion;
}

public String getOrganizationId() {
return organizationId;
}

public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}

public boolean isAzure() {
return isAzure;
}

public void setAzure(boolean azure) {
isAzure = azure;
}

public boolean isGitHubModels() {
return isGitHubModels;
}

public void setGitHubModels(boolean gitHubModels) {
isGitHubModels = gitHubModels;
}

public Duration getTimeout() {
return timeout;
}

public void setTimeout(Duration timeout) {
this.timeout = timeout;
}

public Integer getMaxRetries() {
return maxRetries;
}

public void setMaxRetries(Integer maxRetries) {
this.maxRetries = maxRetries;
}

public Proxy getProxy() {
return proxy;
}

public void setProxy(Proxy proxy) {
this.proxy = proxy;
}

public Map<String, String> getCustomHeaders() {
return customHeaders;
}

public void setCustomHeaders(Map<String, String> customHeaders) {
this.customHeaders = customHeaders;
}

}
Loading