@@ -50,7 +50,7 @@ import com.openai.models.ChatModel;
50
50
import com.openai.models.chat.completions.ChatCompletion ;
51
51
import com.openai.models.chat.completions.ChatCompletionCreateParams ;
52
52
53
- // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID` and `OPENAI_PROJECT_ID ` environment variables
53
+ // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID` and `OPENAI_BASE_URL ` environment variables
54
54
OpenAIClient client = OpenAIOkHttpClient . fromEnv();
55
55
56
56
ChatCompletionCreateParams params = ChatCompletionCreateParams . builder()
@@ -68,7 +68,7 @@ Configure the client using environment variables:
68
68
import com.openai.client.OpenAIClient ;
69
69
import com.openai.client.okhttp.OpenAIOkHttpClient ;
70
70
71
- // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID` and `OPENAI_PROJECT_ID ` environment variables
71
+ // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID` and `OPENAI_BASE_URL ` environment variables
72
72
OpenAIClient client = OpenAIOkHttpClient . fromEnv();
73
73
```
74
74
@@ -90,19 +90,20 @@ import com.openai.client.OpenAIClient;
90
90
import com.openai.client.okhttp.OpenAIOkHttpClient ;
91
91
92
92
OpenAIClient client = OpenAIOkHttpClient . builder()
93
- // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID` and `OPENAI_PROJECT_ID ` environment variables
93
+ // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID` and `OPENAI_BASE_URL ` environment variables
94
94
.fromEnv()
95
95
.apiKey(" My API Key" )
96
96
.build();
97
97
```
98
98
99
99
See this table for the available options:
100
100
101
- | Setter | Environment variable | Required | Default value |
102
- | -------------- | -------------------- | -------- | ------------- |
103
- | ` apiKey ` | ` OPENAI_API_KEY ` | true | - |
104
- | ` organization ` | ` OPENAI_ORG_ID ` | false | - |
105
- | ` project ` | ` OPENAI_PROJECT_ID ` | false | - |
101
+ | Setter | Environment variable | Required | Default value |
102
+ | -------------- | -------------------- | -------- | ----------------------------- |
103
+ | ` apiKey ` | ` OPENAI_API_KEY ` | true | - |
104
+ | ` organization ` | ` OPENAI_ORG_ID ` | false | - |
105
+ | ` project ` | ` OPENAI_PROJECT_ID ` | false | - |
106
+ | ` baseUrl ` | ` OPENAI_BASE_URL ` | true | ` "https://api.openai.com/v1" ` |
106
107
107
108
> [ !TIP]
108
109
> Don't create more than one client in the same application. Each client has a connection pool and
@@ -134,7 +135,7 @@ import com.openai.models.chat.completions.ChatCompletion;
134
135
import com.openai.models.chat.completions.ChatCompletionCreateParams ;
135
136
import java.util.concurrent.CompletableFuture ;
136
137
137
- // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID` and `OPENAI_PROJECT_ID ` environment variables
138
+ // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID` and `OPENAI_BASE_URL ` environment variables
138
139
OpenAIClient client = OpenAIOkHttpClient . fromEnv();
139
140
140
141
ChatCompletionCreateParams params = ChatCompletionCreateParams . builder()
@@ -154,7 +155,7 @@ import com.openai.models.chat.completions.ChatCompletion;
154
155
import com.openai.models.chat.completions.ChatCompletionCreateParams ;
155
156
import java.util.concurrent.CompletableFuture ;
156
157
157
- // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID` and `OPENAI_PROJECT_ID ` environment variables
158
+ // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID` and `OPENAI_BASE_URL ` environment variables
158
159
OpenAIClientAsync client = OpenAIOkHttpClientAsync . fromEnv();
159
160
160
161
ChatCompletionCreateParams params = ChatCompletionCreateParams . builder()
0 commit comments