For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://modelgates.ai/docs/_mcp/server.
Guardrails - Go SDK
The Go SDK and docs are currently in beta. Report issues on GitHub.
Overview
Guardrails endpoints
Available Operations
- List - List guardrails
- Create - Create a guardrail
- Delete - Delete a guardrail
- Get - Get a guardrail
- Update - Update a guardrail
- ListGuardrailKeyAssignments - List key assignments for a guardrail
- BulkAssignKeys - Bulk assign keys to a guardrail
- BulkUnassignKeys - Bulk unassign keys from a guardrail
- ListGuardrailMemberAssignments - List member assignments for a guardrail
- BulkAssignMembers - Bulk assign members to a guardrail
- BulkUnassignMembers - Bulk unassign members from a guardrail
- ListKeyAssignments - List all key assignments
- ListMemberAssignments - List all member assignments
List
List all guardrails for the authenticated user. Management key required.
Example Usage
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.Guardrails.List(ctx, optionalnullable.From[int64](nil), 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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
offset | optionalnullable.OptionalNullable[int64] | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
limit | *int64 | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
workspaceID | *string | :heavy_minus_sign: | Filter guardrails by workspace ID. By default, guardrails in the default workspace are returned. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*operations.ListGuardrailsResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Create
Create a new guardrail for the authenticated user. Management key required.
Example Usage
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.Guardrails.Create(ctx, components.CreateGuardrailRequest{ AllowedModels: optionalnullable.From[[]string](nil), AllowedProviders: optionalnullable.From(modelgates.Pointer([]string{ "openai", "anthropic", "deepseek", })), Description: optionalnullable.From(modelgates.Pointer("A guardrail for limiting API usage")), EnforceZdrAnthropic: optionalnullable.From(modelgates.Pointer(true)), EnforceZdrGoogle: optionalnullable.From(modelgates.Pointer(false)), EnforceZdrOpenai: optionalnullable.From(modelgates.Pointer(true)), EnforceZdrOther: optionalnullable.From(modelgates.Pointer(false)), IgnoredModels: optionalnullable.From[[]string](nil), IgnoredProviders: optionalnullable.From[[]string](nil), LimitUsd: optionalnullable.From(modelgates.Pointer[float64](50.0)), Name: "My New Guardrail", ResetInterval: optionalnullable.From(modelgates.Pointer(components.GuardrailIntervalMonthly)), }) if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. |
request | components.CreateGuardrailRequest | :heavy_check_mark: | The request object to use for the request. |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.CreateGuardrailResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.ForbiddenResponseError | 403 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Delete
Delete an existing guardrail. Management key required.
Example Usage
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.Guardrails.Delete(ctx, "550e8400-e29b-41d4-a716-446655440000") if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail to delete | 550e8400-e29b-41d4-a716-446655440000 |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.DeleteGuardrailResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Get
Get a single guardrail by ID. Management key required.
Example Usage
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.Guardrails.Get(ctx, "550e8400-e29b-41d4-a716-446655440000") if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail to retrieve | 550e8400-e29b-41d4-a716-446655440000 |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.GetGuardrailResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
Update
Update an existing guardrail. Management key required.
Example Usage
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.Guardrails.Update(ctx, "550e8400-e29b-41d4-a716-446655440000", components.UpdateGuardrailRequest{ Description: optionalnullable.From(modelgates.Pointer("Updated description")), LimitUsd: optionalnullable.From(modelgates.Pointer[float64](75.0)), Name: modelgates.Pointer("Updated Guardrail Name"), ResetInterval: optionalnullable.From(modelgates.Pointer(components.GuardrailIntervalWeekly)), }) if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail to update | 550e8400-e29b-41d4-a716-446655440000 |
updateGuardrailRequest | components.UpdateGuardrailRequest | :heavy_check_mark: | N/A | {"description": "Updated description","limit_usd": 75,"name": "Updated Guardrail Name","reset_interval": "weekly"} |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.UpdateGuardrailResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
ListGuardrailKeyAssignments
List all API key assignments for a specific guardrail. Management key required.
Example Usage
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.Guardrails.ListGuardrailKeyAssignments(ctx, "550e8400-e29b-41d4-a716-446655440000", 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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
offset | optionalnullable.OptionalNullable[int64] | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
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.ListGuardrailKeyAssignmentsResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
BulkAssignKeys
Assign multiple API keys to a specific guardrail. Management key required.
Example Usage
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.Guardrails.BulkAssignKeys(ctx, "550e8400-e29b-41d4-a716-446655440000", components.BulkAssignKeysRequest{ KeyHashes: []string{ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", }, }) if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
bulkAssignKeysRequest | components.BulkAssignKeysRequest | :heavy_check_mark: | N/A | {"key_hashes": ["c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"]} |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.BulkAssignKeysResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
BulkUnassignKeys
Unassign multiple API keys from a specific guardrail. Management key required.
Example Usage
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.Guardrails.BulkUnassignKeys(ctx, "550e8400-e29b-41d4-a716-446655440000", components.BulkUnassignKeysRequest{ KeyHashes: []string{ "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93", }, }) if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
bulkUnassignKeysRequest | components.BulkUnassignKeysRequest | :heavy_check_mark: | N/A | {"key_hashes": ["c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"]} |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.BulkUnassignKeysResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
ListGuardrailMemberAssignments
List all organization member assignments for a specific guardrail. Management key required.
Example Usage
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.Guardrails.ListGuardrailMemberAssignments(ctx, "550e8400-e29b-41d4-a716-446655440000", 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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
offset | optionalnullable.OptionalNullable[int64] | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
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.ListGuardrailMemberAssignmentsResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
BulkAssignMembers
Assign multiple organization members to a specific guardrail. Management key required.
Example Usage
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.Guardrails.BulkAssignMembers(ctx, "550e8400-e29b-41d4-a716-446655440000", components.BulkAssignMembersRequest{ MemberUserIds: []string{ "user_abc123", "user_def456", }, }) if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
bulkAssignMembersRequest | components.BulkAssignMembersRequest | :heavy_check_mark: | N/A | {"member_user_ids": ["user_abc123","user_def456"]} |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.BulkAssignMembersResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
BulkUnassignMembers
Unassign multiple organization members from a specific guardrail. Management key required.
Example Usage
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.Guardrails.BulkUnassignMembers(ctx, "550e8400-e29b-41d4-a716-446655440000", components.BulkUnassignMembersRequest{ MemberUserIds: []string{ "user_abc123", "user_def456", }, }) if err != nil { log.Fatal(err) } if res != nil { // handle response }}Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
id | string | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
bulkUnassignMembersRequest | components.BulkUnassignMembersRequest | :heavy_check_mark: | N/A | {"member_user_ids": ["user_abc123","user_def456"]} |
opts | []operations.Option | :heavy_minus_sign: | The options for this request. |
Response
*components.BulkUnassignMembersResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.BadRequestResponseError | 400 | application/json |
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.NotFoundResponseError | 404 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
ListKeyAssignments
List all API key guardrail assignments for the authenticated user. Management key required.
Example Usage
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.Guardrails.ListKeyAssignments(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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
offset | optionalnullable.OptionalNullable[int64] | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
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.ListKeyAssignmentsResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |
ListMemberAssignments
List all organization member guardrail assignments for the authenticated user. Management key required.
Example Usage
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.Guardrails.ListMemberAssignments(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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx | context.Context | :heavy_check_mark: | The context to use for the request. | |
offset | optionalnullable.OptionalNullable[int64] | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
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.ListMemberAssignmentsResponse, error
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.UnauthorizedResponseError | 401 | application/json |
| sdkerrors.InternalServerResponseError | 500 | application/json |
| sdkerrors.APIError | 4XX, 5XX | */* |