For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://modelgates.ai/docs/_mcp/server.

Workspaces - TypeScript SDK

The TypeScript SDK and docs are currently in beta. Report issues on GitHub.

Overview

Workspaces endpoints

Available Operations

list

List all workspaces for the authenticated user. Management key required.

Example Usage

typescript
import { ModelGates } from "@modelgates/sdk"; const modelgates = new ModelGates({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const result = await modelgates.workspaces.list();   for await (const page of result) {    console.log(page);  }} run();

Standalone function

The standalone function version of this method:

typescript
import { ModelGatesCore } from "@modelgates/sdk/core.js";import { workspacesList } from "@modelgates/sdk/funcs/workspacesList.js"; // Use `ModelGatesCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const modelgates = new ModelGatesCore({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const res = await workspacesList(modelgates);  if (res.ok) {    const { value: result } = res;    for await (const page of result) {    console.log(page);  }  } else {    console.log("workspacesList failed:", res.error);  }} run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListWorkspacesRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListWorkspacesResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.InternalServerResponseError500application/json
errors.ModelGatesDefaultError4XX, 5XX*/*

create

Create a new workspace for the authenticated user. Management key required.

Example Usage

typescript
import { ModelGates } from "@modelgates/sdk"; const modelgates = new ModelGates({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const result = await modelgates.workspaces.create({    createWorkspaceRequest: {      defaultImageModel: "openai/dall-e-3",      defaultProviderSort: "price",      defaultTextModel: "openai/gpt-4o",      description: "Production environment workspace",      name: "Production",      slug: "production",    },  });   console.log(result);} run();

Standalone function

The standalone function version of this method:

typescript
import { ModelGatesCore } from "@modelgates/sdk/core.js";import { workspacesCreate } from "@modelgates/sdk/funcs/workspacesCreate.js"; // Use `ModelGatesCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const modelgates = new ModelGatesCore({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const res = await workspacesCreate(modelgates, {    createWorkspaceRequest: {      defaultImageModel: "openai/dall-e-3",      defaultProviderSort: "price",      defaultTextModel: "openai/gpt-4o",      description: "Production environment workspace",      name: "Production",      slug: "production",    },  });  if (res.ok) {    const { value: result } = res;    console.log(result);  } else {    console.log("workspacesCreate failed:", res.error);  }} run();

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateWorkspaceRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.CreateWorkspaceResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.ForbiddenResponseError403application/json
errors.InternalServerResponseError500application/json
errors.ModelGatesDefaultError4XX, 5XX*/*

delete

Delete an existing workspace. The default workspace cannot be deleted. Workspaces with active API keys cannot be deleted. Management key required.

Example Usage

typescript
import { ModelGates } from "@modelgates/sdk"; const modelgates = new ModelGates({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const result = await modelgates.workspaces.delete({    id: "production",  });   console.log(result);} run();

Standalone function

The standalone function version of this method:

typescript
import { ModelGatesCore } from "@modelgates/sdk/core.js";import { workspacesDelete } from "@modelgates/sdk/funcs/workspacesDelete.js"; // Use `ModelGatesCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const modelgates = new ModelGatesCore({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const res = await workspacesDelete(modelgates, {    id: "production",  });  if (res.ok) {    const { value: result } = res;    console.log(result);  } else {    console.log("workspacesDelete failed:", res.error);  }} run();

Parameters

ParameterTypeRequiredDescription
requestoperations.DeleteWorkspaceRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.DeleteWorkspaceResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.ForbiddenResponseError403application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.ModelGatesDefaultError4XX, 5XX*/*

get

Get a single workspace by ID or slug. Management key required.

Example Usage

typescript
import { ModelGates } from "@modelgates/sdk"; const modelgates = new ModelGates({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const result = await modelgates.workspaces.get({    id: "production",  });   console.log(result);} run();

Standalone function

The standalone function version of this method:

typescript
import { ModelGatesCore } from "@modelgates/sdk/core.js";import { workspacesGet } from "@modelgates/sdk/funcs/workspacesGet.js"; // Use `ModelGatesCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const modelgates = new ModelGatesCore({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const res = await workspacesGet(modelgates, {    id: "production",  });  if (res.ok) {    const { value: result } = res;    console.log(result);  } else {    console.log("workspacesGet failed:", res.error);  }} run();

Parameters

ParameterTypeRequiredDescription
requestoperations.GetWorkspaceRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.GetWorkspaceResponse>

Errors

Error TypeStatus CodeContent Type
errors.UnauthorizedResponseError401application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.ModelGatesDefaultError4XX, 5XX*/*

update

Update an existing workspace by ID or slug. Management key required.

Example Usage

typescript
import { ModelGates } from "@modelgates/sdk"; const modelgates = new ModelGates({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const result = await modelgates.workspaces.update({    id: "production",    updateWorkspaceRequest: {      name: "Updated Workspace",      slug: "updated-workspace",    },  });   console.log(result);} run();

Standalone function

The standalone function version of this method:

typescript
import { ModelGatesCore } from "@modelgates/sdk/core.js";import { workspacesUpdate } from "@modelgates/sdk/funcs/workspacesUpdate.js"; // Use `ModelGatesCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const modelgates = new ModelGatesCore({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const res = await workspacesUpdate(modelgates, {    id: "production",    updateWorkspaceRequest: {      name: "Updated Workspace",      slug: "updated-workspace",    },  });  if (res.ok) {    const { value: result } = res;    console.log(result);  } else {    console.log("workspacesUpdate failed:", res.error);  }} run();

Parameters

ParameterTypeRequiredDescription
requestoperations.UpdateWorkspaceRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.UpdateWorkspaceResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.ForbiddenResponseError403application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.ModelGatesDefaultError4XX, 5XX*/*

bulkAddMembers

Add multiple organization members to a workspace. Members are assigned the same role they hold in the organization. Management key required.

Example Usage

typescript
import { ModelGates } from "@modelgates/sdk"; const modelgates = new ModelGates({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const result = await modelgates.workspaces.bulkAddMembers({    id: "production",    bulkAddWorkspaceMembersRequest: {      userIds: [        "user_abc123",        "user_def456",      ],    },  });   console.log(result);} run();

Standalone function

The standalone function version of this method:

typescript
import { ModelGatesCore } from "@modelgates/sdk/core.js";import { workspacesBulkAddMembers } from "@modelgates/sdk/funcs/workspacesBulkAddMembers.js"; // Use `ModelGatesCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const modelgates = new ModelGatesCore({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const res = await workspacesBulkAddMembers(modelgates, {    id: "production",    bulkAddWorkspaceMembersRequest: {      userIds: [        "user_abc123",        "user_def456",      ],    },  });  if (res.ok) {    const { value: result } = res;    console.log(result);  } else {    console.log("workspacesBulkAddMembers failed:", res.error);  }} run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkAddWorkspaceMembersRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.BulkAddWorkspaceMembersResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.ForbiddenResponseError403application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.ModelGatesDefaultError4XX, 5XX*/*

bulkRemoveMembers

Remove multiple members from a workspace. Members with active API keys in the workspace cannot be removed. Management key required.

Example Usage

typescript
import { ModelGates } from "@modelgates/sdk"; const modelgates = new ModelGates({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const result = await modelgates.workspaces.bulkRemoveMembers({    id: "production",    bulkRemoveWorkspaceMembersRequest: {      userIds: [        "user_abc123",        "user_def456",      ],    },  });   console.log(result);} run();

Standalone function

The standalone function version of this method:

typescript
import { ModelGatesCore } from "@modelgates/sdk/core.js";import { workspacesBulkRemoveMembers } from "@modelgates/sdk/funcs/workspacesBulkRemoveMembers.js"; // Use `ModelGatesCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const modelgates = new ModelGatesCore({  httpReferer: "<value>",  appTitle: "<value>",  appCategories: "<value>",  apiKey: process.env["MODELGATES_API_KEY"] ?? "",}); async function run() {  const res = await workspacesBulkRemoveMembers(modelgates, {    id: "production",    bulkRemoveWorkspaceMembersRequest: {      userIds: [        "user_abc123",        "user_def456",      ],    },  });  if (res.ok) {    const { value: result } = res;    console.log(result);  } else {    console.log("workspacesBulkRemoveMembers failed:", res.error);  }} run();

Parameters

ParameterTypeRequiredDescription
requestoperations.BulkRemoveWorkspaceMembersRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.BulkRemoveWorkspaceMembersResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.ForbiddenResponseError403application/json
errors.NotFoundResponseError404application/json
errors.InternalServerResponseError500application/json
errors.ModelGatesDefaultError4XX, 5XX*/*