Skip to content

Commit 69db247

Browse files
authored
Merge pull request elizaOS#1522 from imtms/develop
feat: use OPENAI_API_URL from env to support custom OpenAI API endpoint
2 parents 24b28ee + 65e21a8 commit 69db247

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ DISCORD_VOICE_CHANNEL_ID= # The ID of the voice channel the bot should joi
99

1010
# AI Model API Keys
1111
OPENAI_API_KEY= # OpenAI API key, starting with sk-
12+
OPENAI_API_URL= # OpenAI API Endpoint (optional), Default: https://api.openai.com/v1
1213
SMALL_OPENAI_MODEL= # Default: gpt-4o-mini
1314
MEDIUM_OPENAI_MODEL= # Default: gpt-4o
1415
LARGE_OPENAI_MODEL= # Default: gpt-4o

packages/core/src/embedding.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export async function embed(runtime: IAgentRuntime, input: string) {
189189
if (config.provider === EmbeddingProvider.OpenAI) {
190190
return await getRemoteEmbedding(input, {
191191
model: config.model,
192-
endpoint: "https://api.openai.com/v1",
192+
endpoint: settings.OPENAI_API_URL || "https://api.openai.com/v1",
193193
apiKey: settings.OPENAI_API_KEY,
194194
dimensions: config.dimensions,
195195
});

packages/core/src/models.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Models, ModelProviderName, ModelClass } from "./types.ts";
33

44
export const models: Models = {
55
[ModelProviderName.OPENAI]: {
6-
endpoint: "https://api.openai.com/v1",
6+
endpoint: settings.OPENAI_API_URL || "https://api.openai.com/v1",
77
settings: {
88
stop: [],
99
maxInputTokens: 128000,

0 commit comments

Comments
 (0)