Pipe API: Run beta
The Run API allows you to execute any pipe and receive its response. It supports all use cases of Pipes, including chat interactions, single generation tasks, and function calls.
The Run API supports:
- Single generation requests for straightforward tasks.
- Dynamic variables to create adaptable prompts in real-time.
- Thread management for handling multi-turn conversations.
- Seamless conversation continuation, ensuring smooth transitions across interactions.
If needed, Langbase can store messages and conversation threads, allowing for persistent conversation history for chat use cases.
Run a pipe
Run a pipe by sending the required data with the request. For basic request, send a messages array inside request body.
Required headers
- Name
Content-Type
- Type
- string
- Description
Request content type. Needs to be
application/json
- Name
Authorization
- Type
- string
- Description
Replace
PIPE_API_KEY
with your Pipe API key
Required attributes
- Name
messages
- Type
- array
- Description
An array containing message objects
- Name
messages[0].role
- Type
- string
- Description
The role of the message, i.e.,
system
|user
|assistant
|tool
- Name
messages[0].content
- Type
- string
- Description
The content of the message
Optional attributes
- Name
messages[0].tool_call_id
- Type
- string
- Description
The id of the called LLM tool if the role is
tool
- Name
messages[0].name
- Type
- string
- Description
The name of the called tool if the role is
tool
- Name
variables
- Type
- array
- Description
An array containing different variable objects
- Name
variables[0].name
- Type
- string
- Description
The name of the variable
- Name
variables[0].value
- Type
- string
- Description
The value of the variable
- Name
threadId
- Type
- string
- Description
The ID of an existing chat thread. The conversation will continue in this thread.
Response headers
- Name
lb-thread-id
- Type
- string
- Description
The ID of the new/existing thread. If you want to continue conversation in this thread, send it as
threadId
in the next request.
Basic request without streaming
curl https://api.langbase.com/beta/pipes/run \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer PIPE_API_KEY' \
-d '{
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
}'
Response
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1719848588,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1719848588,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]}
...
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1719848588,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}
Response Header
HTTP/2 200
lb-thread-id: "…-…-…-…-… ID of the thread"
… … … rest of the headers … : … … …