Comment on page
API gateways in LangStream are HTTP/WebSocket endpoints that allow applications to interact with agents via message topics.
LangStream applications can have three different gateway types:
Producer gateways are clients that create a message and write it to a topic.
Consumer gateways are clients that watch a topic for messages from a given position. This gateway can only be accessed via WebSocket.
Chat gateways create a producer client (
questions-topic) and a consumer client (
answers-topic) across one connection, optimized for "chat" style interactions between client and server. This gateway can only be accessed via WebSocket.
Service (topics) gateways create a producer client (
input-topic) and a consumer client (
output-topic), writing a single message and awaiting for the receivement of another message. This gateway can only be accessed via HTTP.
Service (agents) gateways send requests directly to a
serviceagent and return the response to the client. This gateway can only be accessed via HTTP.
Given an application in tenant “my-super-cool-tenant” with an id of “some-application” and the following gateway manifest, 1 gateway of each type is created:
- id: "user-input"
- id: "bot-output"
- id: "chat"
- id: "service"
The corresponding URLs to the gateways would be:
Produce gateway: ws://localhost:8091/produce/my-super-cool-tenant/some-application/user-input
Consume gateway: ws://localhost:8091/consume/my-super-cool-tenant/some-application/bot-output
Chat gateway: ws://localhost:8091/consume/my-super-cool-tenant/some-application/chat
Service gateway: http://localhost:8091/api/gateways/service/my-super-cool-tenant/some-application/service
The URL structure is ws://<control-plane-domain>:<api-gateway-port>/<gateway-type>/<tenant-name>/<application-id>/<gateway-id> for WebSocket.
The URL structure is http://<control-plane-domain>:<api-gateway-port>/api/gateways/<gateway-type>/<tenant-name>/<application-id>/<gateway-id> for HTTP.