Tutorial: Publish a flow as a chat model
Take any deployed Core and register it as a chat model that OpenAI-compatible clients can address by name.
What this gets you#
After publishing, your Core is reachable at:
1 2 | |
Any client that speaks the OpenAI chat completions protocol (the OpenAI SDK in any language, ScaiBot, custom integrations) can use it. Multi-turn conversations work via entity_id (entity-mode Cores) or stateless (default).
Steps#
1. Open your flow#
Load the flow you want to publish — for this tutorial, the Hello World Echo Agent works fine. Anything with an entry_api trigger will do.
2. Toggle the flag#
In the Flow properties panel (click empty canvas to deselect), check Publish as chat model.
A row appears underneath: Visibility group IDs (comma-separated). Leave empty to make the chat model visible to your whole tenant. Restrict to specific ScaiKey group IDs (group_abc, group_xyz) if only a subset should be allowed to call it — members of any listed group will be able to reach it, others get a 403.
3. Save + Deploy#
Click Save, then Deploy. The toast now reads:
1 | |
The published as suffix appears because the deploy step ran a second call (POST /v1/modules/scaicore/cores/{core_id}/publish) after creating the Core.
4. Call it#
1 2 3 4 5 6 7 8 9 10 11 12 | |
Using the OpenAI Python SDK:
1 2 3 4 5 6 7 8 9 10 11 12 | |
How the request reaches your flow#
ScaiGrid's chat completions endpoint resolves scaicore/{tenant}/{slug} to the published Core. It maps the chat-format request into a Core invocation:
- The latest user message text becomes
input.message. - The full message history is available to the Core as
input.messages(for stateful conversation logic). - The response from the Core (typically the
responsefield on the output) is returned as the assistant message.
Your flow can opt into the full message history by looking at messages in its input scope, or stay stateless by only consuming message.
Conversational state#
By default, Cores are stateless — each chat request stands alone. For multi-turn memory:
- Set the Core's instance mode to
entity(currently set viamanifest.scaiflow_meta— canvas doesn't expose it yet). - The client includes
entity_idin the request (typically the conversation/user id). - The Core's state persists across requests with the same
entity_id.
See ScaiCore: Instance modes for the full mechanics.
Toggling publish off#
Setting publish_as_model back to false and re-deploying does NOT currently un-publish — that requires a manual call:
1 2 | |
This will be addressed in a future release (the deploy step will detect the transition and call delete-publish). See Troubleshooting: changing publish state.
Visibility scoping with groups#
"publish_as_model": true,
"model_visibility_group_ids": ["group_acme_eng", "group_acme_ops"]
ScaiGrid forwards these to its model-visibility layer. A user calling /v1/chat/completions with model: scaicore/acme/echo-agent must be a member of at least one of the listed ScaiKey groups, or the call returns 403. Empty list = all tenant users.
Next#
- ScaiCore docs — for instance modes, multi-turn state, and the underlying runtime details.
- ScaiBot docs — for integrating your published Core into ScaiLabs' chat experience.