Production by default
With only acanvas_id, the request runs the version published to Production, the environment every Canvas has. Whenever someone clicks Publish to Production, the next request picks up the new version at once.
cURL
Targeting another environment
Besides Production, a Canvas can have custom environments such asstaging, created in the Publish version dialog with + New environment. To run the version published to one of them, add environment_name next to canvas_id.
environment_name:
- It is the name you gave the environment: lowercase letters, digits and single hyphens between segments, at most 64 characters.
productionis the name of the Production environment. - It only goes with
canvas_id. It cannot be combined withversion_idorapplication_id. - The request fails with
404when the environment does not exist or has no published version.
staging in your test system and the same code pointing at Production in your live system, with the environment name coming from configuration. You publish a version to staging, test it through the API, and only then publish it to Production.
Pinning a version
To run one specific version no matter what gets published, sendversion_id instead of canvas_id. The rest of the request (variables, messages, streaming, async, webhooks) is the same.
version_id in your code. Use an environment when you want the team to publish without a deploy on your side, and a pinned version when the integration must be reviewed before any change.
Knowing which version ran
Every run records the version it used, so you can confirm your setup:- The result of an asynchronous run has a
prompt_version_id. - A completion run listed with
GET /v1/completion-runhaspromptVersionId, and when the request usedenvironment_nameitsmetadata.requestedEnvironmentNameholds the name you sent.
Overriding model settings for one request
The optionaloverride object replaces some settings of the version for that request only, without publishing anything. Its type is required (chat or completion); the other fields are optional:
HTTP body
Overrides are not stored in the Canvas. The
raw_input.override of the run records what was sent. If you need a change for every call, publish a new version instead.