diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 63a3704d8..48f0d34ba 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.19.0" + ".": "5.19.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ddbf18dd..d9b8e7d29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 5.19.1 (2025-09-03) + +Full Changelog: [v5.19.0...v5.19.1](https://github.com/openai/openai-node/compare/v5.19.0...v5.19.1) + +### Bug Fixes + +* **azure:** correctly send API key ([#1635](https://github.com/openai/openai-node/issues/1635)) ([08f6178](https://github.com/openai/openai-node/commit/08f6178ff0d4ccc6b80462c86a36f11eb3bfd5fe)) + ## 5.19.0 (2025-09-03) Full Changelog: [v5.18.1...v5.19.0](https://github.com/openai/openai-node/compare/v5.18.1...v5.19.0) diff --git a/jsr.json b/jsr.json index 968472c49..d6d3f55a9 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@openai/openai", - "version": "5.19.0", + "version": "5.19.1", "exports": { ".": "./index.ts", "./helpers/zod": "./helpers/zod.ts", diff --git a/package.json b/package.json index 7f78591e8..a8fd383fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "5.19.0", + "version": "5.19.1", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/src/azure.ts b/src/azure.ts index 5719fc40c..97765df6d 100644 --- a/src/azure.ts +++ b/src/azure.ts @@ -1,4 +1,6 @@ import type { RequestInit } from './internal/builtin-types'; +import type { NullableHeaders } from './internal/headers'; +import { buildHeaders } from './internal/headers'; import * as Errors from './error'; import { FinalRequestOptions } from './internal/request-options'; import { isObj, readEnv } from './internal/utils'; @@ -134,6 +136,13 @@ export class AzureOpenAI extends OpenAI { } return super.buildRequest(options, props); } + + protected override async authHeaders(opts: FinalRequestOptions): Promise { + if (typeof this._options.apiKey === 'string') { + return buildHeaders([{ 'api-key': this.apiKey }]); + } + return super.authHeaders(opts); + } } const _deployments_endpoints = new Set([ diff --git a/src/client.ts b/src/client.ts index cc2cc0a30..b3c899b44 100644 --- a/src/client.ts +++ b/src/client.ts @@ -331,7 +331,7 @@ export class OpenAI { private fetch: Fetch; #encoder: Opts.RequestEncoder; protected idempotencyHeader?: string; - private _options: ClientOptions; + protected _options: ClientOptions; /** * API Client for interfacing with the OpenAI API. diff --git a/src/version.ts b/src/version.ts index 6bd23c18e..51eae91f3 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '5.19.0'; // x-release-please-version +export const VERSION = '5.19.1'; // x-release-please-version diff --git a/tests/lib/azure.test.ts b/tests/lib/azure.test.ts index b93defab0..82af3ec85 100644 --- a/tests/lib/azure.test.ts +++ b/tests/lib/azure.test.ts @@ -307,6 +307,22 @@ describe('instantiate azure client', () => { }); }); + test('uses api-key header when apiKey is provided', async () => { + const testFetch = async (url: RequestInfo, { headers }: RequestInit = {}): Promise => { + return new Response(JSON.stringify({ a: 1 }), { headers: headers ?? [] }); + }; + const client = new AzureOpenAI({ + baseURL: 'http://localhost:5000/', + apiKey: 'My API Key', + apiVersion, + fetch: testFetch, + }); + + const res = await client.request({ method: 'post', path: 'https://example.com' }).asResponse(); + expect(res.headers.get('api-key')).toEqual('My API Key'); + expect(res.headers.get('authorization')).toEqual(null); + }); + test('with endpoint', () => { const client = new AzureOpenAI({ endpoint: 'https://example.com', apiKey: 'My API Key', apiVersion }); expect(client.baseURL).toEqual('https://example.com/openai');