You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GH-3187: Replace Spring environment variables with custom alternatives
Fixes: #3187
This commit addresses the issue with Spring environment variables that directly
mirror Spring AI application properties, which can confuse users into thinking
they should always set environment variables that match Spring property names.
Instead, we've replaced all instances of SPRING_* prefixed environment variables
in the documentation with custom-named alternatives that are referenced using
Spring Expression Language (SpEL) or retrieved programmatically.
Each documentation section now shows multiple configuration approaches:
- Direct property setting in application.properties/yml
- Using custom environment variables with SpEL
- Accessing environment variables programmatically
This gives users more flexibility while making it clear that using SPRING_*
prefixed environment variables is not required or recommended.
Signed-off-by: Soby Chacko <[email protected]>
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/anthropic-chat.adoc
+33-5
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,42 @@ Spring AI provides dedicated xref:api/chat/bedrock-converse.adoc[Amazon Bedrock
10
10
11
11
== Prerequisites
12
12
13
-
You will need to create an API key on Anthropic portal.
14
-
Create an account at https://console.anthropic.com/dashboard[Anthropic API dashboard] and generate the api key on the https://console.anthropic.com/settings/keys[Get API Keys] page.
13
+
You will need to create an API key on the Anthropic portal.
14
+
15
+
Create an account at https://console.anthropic.com/dashboard[Anthropic API dashboard] and generate the API key on the https://console.anthropic.com/settings/keys[Get API Keys] page.
16
+
15
17
The Spring AI project defines a configuration property named `spring.ai.anthropic.api-key` that you should set to the value of the `API Key` obtained from anthropic.com.
16
-
Exporting an environment variable is one way to set that configuration property:
17
18
18
-
[source,shell]
19
+
You can set this configuration property in your `application.properties` file:
For enhanced security when handling sensitive information like API keys, you can use Spring Expression Language (SpEL) to reference a custom environment variable:
27
+
28
+
[source,yaml]
29
+
----
30
+
# In application.yml
31
+
spring:
32
+
ai:
33
+
anthropic:
34
+
api-key: ${ANTHROPIC_API_KEY}
35
+
----
36
+
37
+
[source,bash]
38
+
----
39
+
# In your environment or .env file
40
+
export ANTHROPIC_API_KEY=<your-anthropic-api-key>
41
+
----
42
+
43
+
You can also set this configuration programmatically in your application code:
For enhanced security when handling sensitive information like API keys, you can use Spring Expression Language (SpEL) to reference custom environment variables:
@@ -31,9 +51,34 @@ To authenticate with the OpenAI service (not Azure), provide an OpenAI API key.
31
51
32
52
When using this approach, set the `spring.ai.azure.openai.chat.options.deployment-name` property to the name of the https://platform.openai.com/docs/models[OpenAI model] you wish to use.
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/deepseek-chat.adoc
+32-4
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,41 @@ Spring AI supports the various AI language models from DeepSeek. You can interac
5
5
== Prerequisites
6
6
7
7
You will need to create an API key with DeepSeek to access DeepSeek language models.
8
+
8
9
Create an account at https://platform.deepseek.com/sign_up[DeepSeek registration page] and generate a token on the https://platform.deepseek.com/api_keys[API Keys page].
9
-
The Spring AI project defines a configuration property named `spring.ai.deepseek.api-key` that you should set to the value of the `API Key` obtained from the https://platform.deepseek.com/api_keys[API Keys page].
10
-
Exporting an environment variable is one way to set this configuration property:
11
10
12
-
[source,shell]
11
+
The Spring AI project defines a configuration property named `spring.ai.deepseek.api-key` that you should set to the value of the `API Key` obtained from the API Keys page.
12
+
13
+
You can set this configuration property in your `application.properties` file:
For enhanced security when handling sensitive information like API keys, you can use Spring Expression Language (SpEL) to reference a custom environment variable:
21
+
22
+
[source,yaml]
23
+
----
24
+
# In application.yml
25
+
spring:
26
+
ai:
27
+
deepseek:
28
+
api-key: ${DEEPSEEK_API_KEY}
29
+
----
30
+
31
+
[source,bash]
32
+
----
33
+
# In your environment or .env file
34
+
export DEEPSEEK_API_KEY=<your-deepseek-api-key>
35
+
----
36
+
37
+
You can also set this configuration programmatically in your application code:
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/groq-chat.adoc
+44-10
Original file line number
Diff line number
Diff line change
@@ -18,21 +18,55 @@ for examples of using Groq with Spring AI.
18
18
19
19
== Prerequisites
20
20
21
-
* Create an API Key.
22
-
Please visit https://console.groq.com/keys[here] to create an API Key.
21
+
* **Create an API Key**:
22
+
Visit https://console.groq.com/keys[here] to create an API Key.
23
23
The Spring AI project defines a configuration property named `spring.ai.openai.api-key` that you should set to the value of the `API Key` obtained from groq.com.
24
-
* Set the Groq URL.
24
+
25
+
* **Set the Groq URL**:
25
26
You have to set the `spring.ai.openai.base-url` property to `https://api.groq.com/openai`.
26
-
* Select a https://console.groq.com/docs/models[Groq Model].
27
-
Use the `spring.ai.openai.chat.options.model=<model name>` property to set the Model.
28
27
29
-
Exporting an environment variable is one way to set that configuration property:
28
+
* **Select a Groq Model**:
29
+
Use the `spring.ai.openai.chat.model=<model name>` property to select from the available https://console.groq.com/docs/models[Groq Models].
30
+
31
+
You can set these configuration properties in your `application.properties` file:
For enhanced security when handling sensitive information like API keys, you can use Spring Expression Language (SpEL) to reference custom environment variables:
30
41
31
-
[source,shell]
42
+
[source,yaml]
43
+
----
44
+
# In application.yml
45
+
spring:
46
+
ai:
47
+
openai:
48
+
api-key: ${GROQ_API_KEY}
49
+
base-url: ${GROQ_BASE_URL}
50
+
chat:
51
+
model: ${GROQ_MODEL}
52
+
----
53
+
54
+
[source,bash]
55
+
----
56
+
# In your environment or .env file
57
+
export GROQ_API_KEY=<your-groq-api-key>
58
+
export GROQ_BASE_URL=https://api.groq.com/openai
59
+
export GROQ_MODEL=llama3-70b-8192
60
+
----
61
+
62
+
You can also set these configurations programmatically in your application code:
63
+
64
+
[source,java]
32
65
----
33
-
export SPRING_AI_OPENAI_API_KEY=<INSERT GROQ API KEY HERE>
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/huggingface.adoc
+41-7
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,49 @@ TIP: For a complete and up-to-date list of supported models and architectures, s
10
10
11
11
You will need to create an Inference Endpoint on Hugging Face and create an API token to access the endpoint.
12
12
Further details can be found link:https://huggingface.co/docs/inference-endpoints/index[here].
13
-
The Spring AI project defines a configuration property named `spring.ai.huggingface.chat.api-key` that you should set to the value of the API token obtained from Hugging Face.
14
-
There is also a configuration property named `spring.ai.huggingface.chat.url` that you should set to the inference endpoint URL obtained when provisioning your model in Hugging Face.
15
-
You can find this on the Inference Endpoint's UI link:https://ui.endpoints.huggingface.co/[here].
16
-
Exporting environment variables is one way to set these configuration properties:
17
13
18
-
[source,shell]
14
+
The Spring AI project defines two configuration properties:
15
+
16
+
1. `spring.ai.huggingface.chat.api-key`: Set this to the value of the API token obtained from Hugging Face.
17
+
2. `spring.ai.huggingface.chat.url`: Set this to the inference endpoint URL obtained when provisioning your model in Hugging Face.
18
+
19
+
You can find your inference endpoint URL on the Inference Endpoint's UI link:https://ui.endpoints.huggingface.co/[here].
20
+
21
+
You can set these configuration properties in your `application.properties` file:
For enhanced security when handling sensitive information like API keys, you can use Spring Expression Language (SpEL) to reference custom environment variables:
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/minimax-chat.adoc
+32-5
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,39 @@ Spring AI supports the various AI language models from MiniMax. You can interact
7
7
You will need to create an API with MiniMax to access MiniMax language models.
8
8
9
9
Create an account at https://www.minimaxi.com/login[MiniMax registration page] and generate the token on the https://www.minimaxi.com/user-center/basic-information/interface-key[API Keys page].
10
-
The Spring AI project defines a configuration property named `spring.ai.minimax.api-key` that you should set to the value of the `API Key` obtained from https://www.minimaxi.com/user-center/basic-information/interface-key[API Keys page].
11
-
Exporting an environment variable is one way to set that configuration property:
12
10
13
-
[source,shell]
11
+
The Spring AI project defines a configuration property named `spring.ai.minimax.api-key` that you should set to the value of the `API Key` obtained from the API Keys page.
12
+
13
+
You can set this configuration property in your `application.properties` file:
14
+
15
+
[source,properties]
16
+
----
17
+
spring.ai.minimax.api-key=<your-minimax-api-key>
18
+
----
19
+
20
+
For enhanced security when handling sensitive information like API keys, you can use Spring Expression Language (SpEL) to reference an environment variable:
21
+
22
+
[source,yaml]
23
+
----
24
+
# In application.yml
25
+
spring:
26
+
ai:
27
+
minimax:
28
+
api-key: ${MINIMAX_API_KEY}
29
+
----
30
+
31
+
[source,bash]
32
+
----
33
+
# In your environment or .env file
34
+
export MINIMAX_API_KEY=<your-minimax-api-key>
35
+
----
36
+
37
+
You can also set this configuration programmatically in your application code:
// Retrieve API key from a secure source or environment variable
42
+
String apiKey = System.getenv("MINIMAX_API_KEY");
16
43
----
17
44
18
45
=== Add Repositories and BOM
@@ -298,4 +325,4 @@ Flux<ChatResponse> streamResponse = chatModel.stream(new Prompt(this.messages, t
298
325
==== MiniMaxApi Samples
299
326
* The link:https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxApiIT.java[MiniMaxApiIT.java] test provides some general examples how to use the lightweight library.
300
327
301
-
* The link:https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxApiToolFunctionCallIT.java[MiniMaxApiToolFunctionCallIT.java] test shows how to use the low-level API to call tool functions.>
328
+
* The link:https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxApiToolFunctionCallIT.java[MiniMaxApiToolFunctionCallIT.java] test shows how to use the low-level API to call tool functions.>
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/mistralai-chat.adoc
+31-3
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,41 @@ Check the xref:_openai_api_compatibility[OpenAI API compatibility] section to le
8
8
== Prerequisites
9
9
10
10
You will need to create an API with Mistral AI to access Mistral AI language models.
11
+
11
12
Create an account at https://auth.mistral.ai/ui/registration[Mistral AI registration page] and generate the token on the https://console.mistral.ai/api-keys/[API Keys page].
13
+
12
14
The Spring AI project defines a configuration property named `spring.ai.mistralai.api-key` that you should set to the value of the `API Key` obtained from console.mistral.ai.
13
-
Exporting an environment variable is one way to set that configuration property:
14
15
15
-
[source,shell]
16
+
You can set this configuration property in your `application.properties` file:
For enhanced security when handling sensitive information like API keys, you can use Spring Expression Language (SpEL) to reference a custom environment variable:
24
+
25
+
[source,yaml]
26
+
----
27
+
# In application.yml
28
+
spring:
29
+
ai:
30
+
mistralai:
31
+
api-key: ${MISTRALAI_API_KEY}
32
+
----
33
+
34
+
[source,bash]
35
+
----
36
+
# In your environment or .env file
37
+
export MISTRALAI_API_KEY=<your-mistralai-api-key>
38
+
----
39
+
40
+
You can also set this configuration programmatically in your application code:
0 commit comments