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 workspaces
- create - Create a workspace
- delete - Delete a workspace
- get - Get a workspace
- update - Update a workspace
- bulkAddMembers - Bulk add members to a workspace
- bulkRemoveMembers - Bulk remove members from a workspace
list
List all workspaces for the authenticated user. Management key required.
Example Usage
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:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListWorkspacesRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :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.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListWorkspacesResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ModelGatesDefaultError | 4XX, 5XX | */* |
create
Create a new workspace for the authenticated user. Management key required.
Example Usage
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:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.CreateWorkspaceRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :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.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.CreateWorkspaceResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ModelGatesDefaultError | 4XX, 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
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:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.DeleteWorkspaceRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :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.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.DeleteWorkspaceResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ModelGatesDefaultError | 4XX, 5XX | */* |
get
Get a single workspace by ID or slug. Management key required.
Example Usage
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:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetWorkspaceRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :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.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.GetWorkspaceResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ModelGatesDefaultError | 4XX, 5XX | */* |
update
Update an existing workspace by ID or slug. Management key required.
Example Usage
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:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.UpdateWorkspaceRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :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.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.UpdateWorkspaceResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ModelGatesDefaultError | 4XX, 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
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:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.BulkAddWorkspaceMembersRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :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.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.BulkAddWorkspaceMembersResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ModelGatesDefaultError | 4XX, 5XX | */* |
bulkRemoveMembers
Remove multiple members from a workspace. Members with active API keys in the workspace cannot be removed. Management key required.
Example Usage
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:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.BulkRemoveWorkspaceMembersRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :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.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.BulkRemoveWorkspaceMembersResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ModelGatesDefaultError | 4XX, 5XX | */* |