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

Workspaces - Go SDK

The Go 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

go
package main import(	"context"	"os"	modelgates "github.com/ModelGatesTeam/go-sdk"	"github.com/ModelGatesTeam/go-sdk/optionalnullable"	"log") func main() {    ctx := context.Background()     s := modelgates.New(        modelgates.WithSecurity(os.Getenv("MODELGATES_API_KEY")),    )     res, err := s.Workspaces.List(ctx, optionalnullable.From[int64](nil), nil)    if err != nil {        log.Fatal(err)    }    if res != nil {        for {            // handle items             res, err = res.Next()             if err != nil {                // handle error            }             if res == nil {                break            }        }    }}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
offsetoptionalnullable.OptionalNullable[int64]:heavy_minus_sign:Number of records to skip for pagination0
limit*int64:heavy_minus_sign:Maximum number of records to return (max 100)50
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*operations.ListWorkspacesResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*

Create

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

Example Usage

go
package main import(	"context"	"os"	modelgates "github.com/ModelGatesTeam/go-sdk"	"github.com/ModelGatesTeam/go-sdk/optionalnullable"	"github.com/ModelGatesTeam/go-sdk/models/components"	"log") func main() {    ctx := context.Background()     s := modelgates.New(        modelgates.WithSecurity(os.Getenv("MODELGATES_API_KEY")),    )     res, err := s.Workspaces.Create(ctx, components.CreateWorkspaceRequest{        DefaultImageModel: optionalnullable.From(modelgates.Pointer("openai/dall-e-3")),        DefaultProviderSort: optionalnullable.From(modelgates.Pointer("price")),        DefaultTextModel: optionalnullable.From(modelgates.Pointer("openai/gpt-4o")),        Description: optionalnullable.From(modelgates.Pointer("Production environment workspace")),        Name: "Production",        Slug: "production",    })    if err != nil {        log.Fatal(err)    }    if res != nil {        // handle response    }}

Parameters

ParameterTypeRequiredDescription
ctxcontext.Context:heavy_check_mark:The context to use for the request.
requestcomponents.CreateWorkspaceRequest:heavy_check_mark:The request object to use for the request.
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*components.CreateWorkspaceResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.ForbiddenResponseError403application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 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

go
package main import(	"context"	"os"	modelgates "github.com/ModelGatesTeam/go-sdk"	"log") func main() {    ctx := context.Background()     s := modelgates.New(        modelgates.WithSecurity(os.Getenv("MODELGATES_API_KEY")),    )     res, err := s.Workspaces.Delete(ctx, "production")    if err != nil {        log.Fatal(err)    }    if res != nil {        // handle response    }}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
idstring:heavy_check_mark:The workspace ID (UUID) or slugproduction
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*components.DeleteWorkspaceResponse, error

Errors

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

Get

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

Example Usage

go
package main import(	"context"	"os"	modelgates "github.com/ModelGatesTeam/go-sdk"	"log") func main() {    ctx := context.Background()     s := modelgates.New(        modelgates.WithSecurity(os.Getenv("MODELGATES_API_KEY")),    )     res, err := s.Workspaces.Get(ctx, "production")    if err != nil {        log.Fatal(err)    }    if res != nil {        // handle response    }}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
idstring:heavy_check_mark:The workspace ID (UUID) or slugproduction
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*components.GetWorkspaceResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*

Update

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

Example Usage

go
package main import(	"context"	"os"	modelgates "github.com/ModelGatesTeam/go-sdk"	"github.com/ModelGatesTeam/go-sdk/models/components"	"log") func main() {    ctx := context.Background()     s := modelgates.New(        modelgates.WithSecurity(os.Getenv("MODELGATES_API_KEY")),    )     res, err := s.Workspaces.Update(ctx, "production", components.UpdateWorkspaceRequest{        Name: modelgates.Pointer("Updated Workspace"),        Slug: modelgates.Pointer("updated-workspace"),    })    if err != nil {        log.Fatal(err)    }    if res != nil {        // handle response    }}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
idstring:heavy_check_mark:The workspace ID (UUID) or slugproduction
updateWorkspaceRequestcomponents.UpdateWorkspaceRequest:heavy_check_mark:N/A{"name": "Updated Workspace","slug": "updated-workspace"}
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*components.UpdateWorkspaceResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.ForbiddenResponseError403application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 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

go
package main import(	"context"	"os"	modelgates "github.com/ModelGatesTeam/go-sdk"	"github.com/ModelGatesTeam/go-sdk/models/components"	"log") func main() {    ctx := context.Background()     s := modelgates.New(        modelgates.WithSecurity(os.Getenv("MODELGATES_API_KEY")),    )     res, err := s.Workspaces.BulkAddMembers(ctx, "production", components.BulkAddWorkspaceMembersRequest{        UserIds: []string{            "user_abc123",            "user_def456",        },    })    if err != nil {        log.Fatal(err)    }    if res != nil {        // handle response    }}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
idstring:heavy_check_mark:The workspace ID (UUID) or slugproduction
bulkAddWorkspaceMembersRequestcomponents.BulkAddWorkspaceMembersRequest:heavy_check_mark:N/A{"user_ids": ["user_abc123","user_def456"]}
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*components.BulkAddWorkspaceMembersResponse, error

Errors

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

BulkRemoveMembers

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

Example Usage

go
package main import(	"context"	"os"	modelgates "github.com/ModelGatesTeam/go-sdk"	"github.com/ModelGatesTeam/go-sdk/models/components"	"log") func main() {    ctx := context.Background()     s := modelgates.New(        modelgates.WithSecurity(os.Getenv("MODELGATES_API_KEY")),    )     res, err := s.Workspaces.BulkRemoveMembers(ctx, "production", components.BulkRemoveWorkspaceMembersRequest{        UserIds: []string{            "user_abc123",            "user_def456",        },    })    if err != nil {        log.Fatal(err)    }    if res != nil {        // handle response    }}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
idstring:heavy_check_mark:The workspace ID (UUID) or slugproduction
bulkRemoveWorkspaceMembersRequestcomponents.BulkRemoveWorkspaceMembersRequest:heavy_check_mark:N/A{"user_ids": ["user_abc123","user_def456"]}
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*components.BulkRemoveWorkspaceMembersResponse, error

Errors

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