Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openai/openai-node
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.24.2
Choose a base ref
...
head repository: openai/openai-node
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.24.3
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Jan 10, 2024

  1. fix: use default base url if BASE_URL env var is blank (#615)

    Previously, a blank BASE_URL environment variable would cause an invalid URL error. Now it uses the default.
    stainless-bot committed Jan 10, 2024

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    cc1bf07 View commit details
  2. release: 4.24.3

    stainless-bot committed Jan 10, 2024

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    406e502 View commit details
Showing with 31 additions and 9 deletions.
  1. +1 −1 .release-please-manifest.json
  2. +8 −0 CHANGELOG.md
  3. +1 −1 README.md
  4. +1 −1 build-deno
  5. +1 −1 package.json
  6. +4 −2 src/core.ts
  7. +1 −1 src/index.ts
  8. +1 −1 src/version.ts
  9. +13 −1 tests/index.test.ts
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.24.2"
".": "4.24.3"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.24.3 (2024-01-10)

Full Changelog: [v4.24.2...v4.24.3](https://github.com/openai/openai-node/compare/v4.24.2...v4.24.3)

### Bug Fixes

* use default base url if BASE_URL env var is blank ([#615](https://github.com/openai/openai-node/issues/615)) ([a27ad3d](https://github.com/openai/openai-node/commit/a27ad3d4e06f2202daa169668d0e7d89e87a38a7))

## 4.24.2 (2024-01-08)

Full Changelog: [v4.24.1...v4.24.2](https://github.com/openai/openai-node/compare/v4.24.1...v4.24.2)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ You can import in Deno via:
<!-- x-release-please-start-version -->

```ts
import OpenAI from 'https://deno.land/x/openai@v4.24.2/mod.ts';
import OpenAI from 'https://deno.land/x/openai@v4.24.3/mod.ts';
```

<!-- x-release-please-end -->
2 changes: 1 addition & 1 deletion build-deno
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ This is a build produced from https://github.com/openai/openai-node – please g
Usage:
\`\`\`ts
import OpenAI from "https://deno.land/x/openai@v4.24.2/mod.ts";
import OpenAI from "https://deno.land/x/openai@v4.24.3/mod.ts";
const client = new OpenAI();
\`\`\`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openai",
"version": "4.24.2",
"version": "4.24.3",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI <support@openai.com>",
"types": "dist/index.d.ts",
6 changes: 4 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -961,14 +961,16 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
/**
* Read an environment variable.
*
* Trims beginning and trailing whitespace.
*
* Will return undefined if the environment variable doesn't exist or cannot be accessed.
*/
export const readEnv = (env: string): string | undefined => {
if (typeof process !== 'undefined') {
return process.env?.[env] ?? undefined;
return process.env?.[env]?.trim() ?? undefined;
}
if (typeof Deno !== 'undefined') {
return Deno.env?.get?.(env);
return Deno.env?.get?.(env)?.trim();
}
return undefined;
};
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ export class OpenAI extends Core.APIClient {
apiKey,
organization,
...opts,
baseURL: baseURL ?? `https://api.openai.com/v1`,
baseURL: baseURL || `https://api.openai.com/v1`,
};

if (!options.dangerouslyAllowBrowser && Core.isRunningInBrowser()) {
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '4.24.2'; // x-release-please-version
export const VERSION = '4.24.3'; // x-release-please-version
14 changes: 13 additions & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ describe('instantiate client', () => {
});

afterEach(() => {
process.env['SINK_BASE_URL'] = undefined;
process.env['OPENAI_BASE_URL'] = undefined;
});

test('explicit option', () => {
@@ -147,6 +147,18 @@ describe('instantiate client', () => {
const client = new OpenAI({ apiKey: 'My API Key' });
expect(client.baseURL).toEqual('https://example.com/from_env');
});

test('empty env variable', () => {
process.env['OPENAI_BASE_URL'] = ''; // empty
const client = new OpenAI({ apiKey: 'My API Key' });
expect(client.baseURL).toEqual('https://api.openai.com/v1');
});

test('blank env variable', () => {
process.env['OPENAI_BASE_URL'] = ' '; // blank
const client = new OpenAI({ apiKey: 'My API Key' });
expect(client.baseURL).toEqual('https://api.openai.com/v1');
});
});

test('maxRetries option is correctly set', () => {