Skip to content
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.1.1"
".": "4.2.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-e864d762f50e49c0584bbf35eacc43cdb1397f805cca52cb8d4c07781739d0a3.yml
openapi_spec_hash: f511fefb34946e5878ac17f2b3056b1f
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-cbf656f40e43acf60d9596f78204f031dc8c7205626df8f05ce8e88bcf49b597.yml
openapi_spec_hash: 23be5a56248a1a575b34833eb7e7fe49
config_hash: 9d144cc6c49d3fd53e5b4472c1e22165
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 4.2.0 (2026-06-01)

Full Changelog: [v4.1.1...v4.2.0](https://github.com/moderation-api/sdk-typescript/compare/v4.1.1...v4.2.0)

### Features

* **api:** api update ([3e63e9b](https://github.com/moderation-api/sdk-typescript/commit/3e63e9b0cc49dd5c18a47ad1917fd835a9ca6628))
* **api:** api update ([1ffcc3b](https://github.com/moderation-api/sdk-typescript/commit/1ffcc3bc1df790e111b95697dd3a520a0d8d0f97))
* **api:** api update ([cc909b9](https://github.com/moderation-api/sdk-typescript/commit/cc909b999d8790d84b69693d773334f5361e75b5))

## 4.1.1 (2026-05-19)

Full Changelog: [v4.1.0...v4.1.1](https://github.com/moderation-api/sdk-typescript/compare/v4.1.0...v4.1.1)
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const moderationApi = new ModerationAPI({
});
```

const response = await client.content.submit({ content: { text: 'text', type: 'text' } });

### Content Moderation

Use `content.submit` to moderate text, images, video, audio, or complex objects:
Expand Down Expand Up @@ -198,7 +200,7 @@ import ModerationAPI from '@moderation-api/sdk';

const client = new ModerationAPI();

const params: ModerationAPI.ContentSubmitParams = { content: { text: 'x', type: 'text' } };
const params: ModerationAPI.ContentSubmitParams = { content: { text: 'text', type: 'text' } };
const response: ModerationAPI.ContentSubmitResponse = await client.content.submit(params);
```

Expand All @@ -213,7 +215,7 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
const response = await client.content
.submit({ content: { text: 'x', type: 'text' } })
.submit({ content: { text: 'text', type: 'text' } })
.catch(async (err) => {
if (err instanceof ModerationAPI.APIError) {
console.log(err.status); // 400
Expand Down Expand Up @@ -254,7 +256,7 @@ const client = new ModerationAPI({
});

// Or, configure per-request:
await client.content.submit({ content: { text: 'x', type: 'text' } }, {
await client.content.submit({ content: { text: 'text', type: 'text' } }, {
maxRetries: 5,
});
```
Expand All @@ -271,7 +273,7 @@ const client = new ModerationAPI({
});

// Override per-request:
await client.content.submit({ content: { text: 'x', type: 'text' } }, {
await client.content.submit({ content: { text: 'text', type: 'text' } }, {
timeout: 5 * 1000,
});
```
Expand All @@ -294,12 +296,14 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
```ts
const client = new ModerationAPI();

const response = await client.content.submit({ content: { text: 'x', type: 'text' } }).asResponse();
const response = await client.content
.submit({ content: { text: 'text', type: 'text' } })
.asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: response, response: raw } = await client.content
.submit({ content: { text: 'x', type: 'text' } })
.submit({ content: { text: 'text', type: 'text' } })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(response.recommendation);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moderation-api/sdk",
"version": "4.1.1",
"version": "4.2.0",
"description": "The official TypeScript library for the Moderation API API",
"author": "Moderation API <support@moderationapi.com>",
"types": "dist/index.d.ts",
Expand Down
42 changes: 42 additions & 0 deletions src/resources/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ export namespace ContentSubmitResponse {

type: 'classifier';

/**
* Optional structured data produced by the policy. For face detection: { count,
* faces: [{ confidence, gender, age }] }.
*/
data?: { [key: string]: unknown };

/**
* The keys of the flagged fields if submitting an object.
*/
Expand Down Expand Up @@ -502,6 +508,8 @@ export interface ContentSubmitParams {
| ContentSubmitParams.Violence
| ContentSubmitParams.SelfHarm
| ContentSubmitParams.Spam
| ContentSubmitParams.LowQualityContent
| ContentSubmitParams.FaceDetection
| ContentSubmitParams.SelfPromotion
| ContentSubmitParams.Political
| ContentSubmitParams.Religion
Expand Down Expand Up @@ -794,6 +802,40 @@ export namespace ContentSubmitParams {
threshold?: number;
}

export interface LowQualityContent {
id: 'low_quality';

flag: boolean;

/**
* Flag content with fewer than this many words as low-effort. Defaults to 3. Set
* to disable by omitting.
*/
minWords?: number;

threshold?: number;
}

export interface FaceDetection {
id: 'face_detection';

flag: boolean;

/**
* Flag images that contain "at least" or "fewer than" the configured number of
* faces. Defaults to at_least.
*/
comparator?: 'at_least' | 'fewer_than';

/**
* Number of faces the comparator applies to. Defaults to 1, so the default rule
* flags any image containing a face.
*/
count?: number;

threshold?: number;
}

export interface SelfPromotion {
id: 'self_promotion';

Expand Down
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.1.1'; // x-release-please-version
export const VERSION = '4.2.0'; // x-release-please-version
4 changes: 2 additions & 2 deletions tests/api-resources/content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const client = new ModerationAPI({
describe('resource content', () => {
// Mock server tests are disabled
test.skip('submit: only required params', async () => {
const responsePromise = client.content.submit({ content: { text: 'x', type: 'text' } });
const responsePromise = client.content.submit({ content: { text: 'text', type: 'text' } });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -23,7 +23,7 @@ describe('resource content', () => {
// Mock server tests are disabled
test.skip('submit: required and optional params', async () => {
const response = await client.content.submit({
content: { text: 'x', type: 'text' },
content: { text: 'text', type: 'text' },
authorId: 'authorId',
channel: 'channel',
contentId: 'contentId',
Expand Down
Loading