Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 4.53.0 #947

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.52.7"
".": "4.53.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 64
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-27d8d6da893c1cdd53b491ec05153df22b1e113965f253a1d6eb8d75b628173f.yml
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-77cfff37114bc9f141c7e6107eb5f1b38d8cc99bc3d4ce03a066db2b6b649c69.yml
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 4.53.0 (2024-07-22)

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

### Features

* **api:** add new gpt-4o-mini models ([#942](https://github.com/openai/openai-node/issues/942)) ([7ac10dd](https://github.com/openai/openai-node/commit/7ac10ddbb87e9eb0e8e34d58a13a4775cbba1c24))
* **api:** add uploads endpoints ([#946](https://github.com/openai/openai-node/issues/946)) ([8709ceb](https://github.com/openai/openai-node/commit/8709ceb0e01c5a1f96704c998f35ca1117ecadac))


### Chores

* **docs:** mention support of web browser runtimes ([#938](https://github.com/openai/openai-node/issues/938)) ([123d19d](https://github.com/openai/openai-node/commit/123d19d5a157110c8ada556c107caf0eb8b2ccc6))
* **docs:** use client instead of package name in Node examples ([#941](https://github.com/openai/openai-node/issues/941)) ([8b5db1f](https://github.com/openai/openai-node/commit/8b5db1f53e66ce4b6e554f40a8dd2fd474085027))

## 4.52.7 (2024-07-11)

Full Changelog: [v4.52.6...v4.52.7](https://github.com/openai/openai-node/compare/v4.52.6...v4.52.7)
Expand Down
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can import in Deno via:
<!-- x-release-please-start-version -->

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

<!-- x-release-please-end -->
Expand All @@ -32,7 +32,7 @@ The full API of this library can be found in [api.md file](api.md) along with ma
```js
import OpenAI from 'openai';

const openai = new OpenAI({
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

Expand All @@ -53,7 +53,7 @@ We provide support for streaming responses using Server Sent Events (SSE).
```ts
import OpenAI from 'openai';

const openai = new OpenAI();
const client = new OpenAI();

async function main() {
const stream = await openai.chat.completions.create({
Expand All @@ -80,7 +80,7 @@ This library includes TypeScript definitions for all request params and response
```ts
import OpenAI from 'openai';

const openai = new OpenAI({
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

Expand Down Expand Up @@ -301,7 +301,7 @@ import fs from 'fs';
import fetch from 'node-fetch';
import OpenAI, { toFile } from 'openai';

const openai = new OpenAI();
const client = new OpenAI();

// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
await openai.files.create({ file: fs.createReadStream('input.jsonl'), purpose: 'fine-tune' });
Expand Down Expand Up @@ -399,7 +399,7 @@ You can use the `maxRetries` option to configure or disable this:
<!-- prettier-ignore -->
```js
// Configure the default for all requests:
const openai = new OpenAI({
const client = new OpenAI({
maxRetries: 0, // default is 2
});

Expand All @@ -416,7 +416,7 @@ Requests time out after 10 minutes by default. You can configure this with a `ti
<!-- prettier-ignore -->
```ts
// Configure the default for all requests:
const openai = new OpenAI({
const client = new OpenAI({
timeout: 20 * 1000, // 20 seconds (default is 10 minutes)
});

Expand Down Expand Up @@ -471,7 +471,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi

<!-- prettier-ignore -->
```ts
const openai = new OpenAI();
const client = new OpenAI();

const response = await openai.chat.completions
.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'gpt-3.5-turbo' })
Expand Down Expand Up @@ -582,7 +582,7 @@ import http from 'http';
import { HttpsProxyAgent } from 'https-proxy-agent';

// Configure the default for all requests:
const openai = new OpenAI({
const client = new OpenAI({
httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),
});

Expand Down Expand Up @@ -617,6 +617,18 @@ The following runtimes are supported:
- Vercel Edge Runtime.
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.
- Web browsers: disabled by default to avoid exposing your secret API credentials. Enable browser support by explicitly setting `dangerouslyAllowBrowser` to true'.
<details>
<summary>More explanation</summary>
### Why is this dangerous?
Enabling the `dangerouslyAllowBrowser` option can be dangerous because it exposes your secret API credentials in the client-side code. Web browsers are inherently less secure than server environments,
any user with access to the browser can potentially inspect, extract, and misuse these credentials. This could lead to unauthorized access using your credentials and potentially compromise sensitive data or functionality.
### When might this not be dangerous?
In certain scenarios where enabling browser support might not pose significant risks:
- Internal Tools: If the application is used solely within a controlled internal environment where the users are trusted, the risk of credential exposure can be mitigated.
- Public APIs with Limited Scope: If your API has very limited scope and the exposed credentials do not grant access to sensitive data or critical operations, the potential impact of exposure is reduced.
- Development or debugging purpose: Enabling this feature temporarily might be acceptable, provided the credentials are short-lived, aren't also used in production environments, or are frequently rotated.
</details>

Note that React Native is not supported at this time.

Expand Down
22 changes: 22 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,25 @@ Methods:
- <code title="get /batches/{batch_id}">client.batches.<a href="./src/resources/batches.ts">retrieve</a>(batchId) -> Batch</code>
- <code title="get /batches">client.batches.<a href="./src/resources/batches.ts">list</a>({ ...params }) -> BatchesPage</code>
- <code title="post /batches/{batch_id}/cancel">client.batches.<a href="./src/resources/batches.ts">cancel</a>(batchId) -> Batch</code>

# Uploads

Types:

- <code><a href="./src/resources/uploads/uploads.ts">Upload</a></code>

Methods:

- <code title="post /uploads">client.uploads.<a href="./src/resources/uploads/uploads.ts">create</a>({ ...params }) -> Upload</code>
- <code title="post /uploads/{upload_id}/cancel">client.uploads.<a href="./src/resources/uploads/uploads.ts">cancel</a>(uploadId) -> Upload</code>
- <code title="post /uploads/{upload_id}/complete">client.uploads.<a href="./src/resources/uploads/uploads.ts">complete</a>(uploadId, { ...params }) -> Upload</code>

## Parts

Types:

- <code><a href="./src/resources/uploads/parts.ts">UploadPart</a></code>

Methods:

- <code title="post /uploads/{upload_id}/parts">client.uploads.parts.<a href="./src/resources/uploads/parts.ts">create</a>(uploadId, { ...params }) -> UploadPart</code>
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.52.7",
"version": "4.53.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI <support@openai.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-deno
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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.52.7/mod.ts";
import OpenAI from "https://deno.land/x/openai@v4.53.0/mod.ts";

const client = new OpenAI();
\`\`\`
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export class OpenAI extends Core.APIClient {
fineTuning: API.FineTuning = new API.FineTuning(this);
beta: API.Beta = new API.Beta(this);
batches: API.Batches = new API.Batches(this);
uploads: API.Uploads = new API.Uploads(this);

protected override defaultQuery(): Core.DefaultQuery | undefined {
return this._options.defaultQuery;
Expand Down Expand Up @@ -309,6 +310,11 @@ export namespace OpenAI {
export import BatchCreateParams = API.BatchCreateParams;
export import BatchListParams = API.BatchListParams;

export import Uploads = API.Uploads;
export import Upload = API.Upload;
export import UploadCreateParams = API.UploadCreateParams;
export import UploadCompleteParams = API.UploadCompleteParams;

export import ErrorObject = API.ErrorObject;
export import FunctionDefinition = API.FunctionDefinition;
export import FunctionParameters = API.FunctionParameters;
Expand Down
2 changes: 2 additions & 0 deletions src/resources/beta/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,8 @@ export interface AssistantCreateParams {
| (string & {})
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-0125-preview'
Expand Down
2 changes: 2 additions & 0 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,8 @@ export interface RunCreateParamsBase {
| (string & {})
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-0125-preview'
Expand Down
2 changes: 2 additions & 0 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ export interface ThreadCreateAndRunParamsBase {
| (string & {})
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-0125-preview'
Expand Down
2 changes: 2 additions & 0 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export class Chat extends APIResource {
export type ChatModel =
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-0125-preview'
Expand Down
1 change: 1 addition & 0 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ export interface ChatCompletionCreateParamsBase {
* exhausted.
* - If set to 'default', the request will be processed using the default service
* tier with a lower uptime SLA and no latency guarentee.
* - When not set, the default behavior is 'auto'.
*
* When this parameter is set, the response body will include the `service_tier`
* utilized.
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ export {
} from './images';
export { Model, ModelDeleted, ModelsPage, Models } from './models';
export { Moderation, ModerationCreateResponse, ModerationCreateParams, Moderations } from './moderations';
export { Upload, UploadCreateParams, UploadCompleteParams, Uploads } from './uploads/uploads';
4 changes: 4 additions & 0 deletions src/resources/uploads/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Upload, UploadCreateParams, UploadCompleteParams, Uploads } from './uploads';
export { UploadPart, PartCreateParams, Parts } from './parts';
68 changes: 68 additions & 0 deletions src/resources/uploads/parts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as PartsAPI from './parts';

export class Parts extends APIResource {
/**
* Adds a
* [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an
* [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object.
* A Part represents a chunk of bytes from the file you are trying to upload.
*
* Each Part can be at most 64 MB, and you can add Parts until you hit the Upload
* maximum of 8 GB.
*
* It is possible to add multiple Parts in parallel. You can decide the intended
* order of the Parts when you
* [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
*/
create(
uploadId: string,
body: PartCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<UploadPart> {
return this._client.post(
`/uploads/${uploadId}/parts`,
Core.multipartFormRequestOptions({ body, ...options }),
);
}
}

/**
* The upload Part represents a chunk of bytes we can add to an Upload object.
*/
export interface UploadPart {
/**
* The upload Part unique identifier, which can be referenced in API endpoints.
*/
id: string;

/**
* The Unix timestamp (in seconds) for when the Part was created.
*/
created_at: number;

/**
* The object type, which is always `upload.part`.
*/
object: 'upload.part';

/**
* The ID of the Upload object that this Part was added to.
*/
upload_id: string;
}

export interface PartCreateParams {
/**
* The chunk of bytes for this Part.
*/
data: Core.Uploadable;
}

export namespace Parts {
export import UploadPart = PartsAPI.UploadPart;
export import PartCreateParams = PartsAPI.PartCreateParams;
}
Loading
Loading