Skip to main content

Availability

Workspaces are available from Tyk AI Studio 2.3.0. An automated client, such as a CI pipeline or a script, manages AI Studio objects through the management API. It also pushes configuration to the Edge Gateways. Give the client its own Workspace so that it manages only its own objects. For how Workspaces work, refer to Workspaces.

Set Up the Client

  1. Create a service account. Go to Access > Users, click Add user, and set Account type to Service account. Copy the API key. AI Studio shows the key one time only. Refer to Service Accounts.
  2. Create a Workspace for the client. Go to Access > Workspaces and click Add Workspace.
  3. Give the service account a role in that Workspace. On the Access tab of the Workspace, add the service account with the Editor role. A custom role with fewer permissions also works.
  4. Give the service account a global role for pushes. Create a custom role with only the edges:read and edges:execute permissions. Assign it to the service account as a global role, in the Roles field of the user.
  5. Create a namespace for each Team that the client pushes to.

Push Only the Changes of the Workspace

The client lists and changes only the objects of its Workspace. Before a push, it reads the pending changes of the namespace for its Workspace. The stained and outside_total fields show if changes from other Workspaces are pending. To push only when no such changes are pending, the client sends only_workspace_id in the push request. For the request format, refer to the AI Studio API.
  • If changes from other Workspaces are pending, AI Studio returns 409 with the code push_stained, and does not push.
  • Objects with no Workspace, such as plugins and model prices, count as changes from other Workspaces.
If changes from other Workspaces are pending when the client starts, its first push with only_workspace_id fails. To start clean, push the namespace one time from the admin console before you start the client.

Example API Calls

This example shows the setup and the calls of the client. $ADMIN_KEY is the API key of an administrator, and $SA_KEY is the API key of the service account. The IDs are examples.