Pipe: Run v1
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.
Headers
- Name
Content-Type
- Type
- string
- Required
- Required
- Description
Request content type. Needs to be
application/json
- Name
Authorization
- Type
- string
- Required
- Required
- Description
Replace
PIPE_API_KEY
with your Pipe API key
Body Parameters
- Name
messages
- Type
- Array<Message>
- Required
- Required
- Description
An array containing message objects.
Message Object
interface Message { role: string; content?: string | ContentType[] | null; tool_call_id?: string; name?: string; }
- Name
role
- Type
- string
- Required
- Required
- Description
The role of the message, i.e.,
system
|user
|assistant
|tool
- Name
content
- Type
- string | ContentType[] | null
- Description
The content of the message.
-
String
For text generation, it's a plain string. -
Null
orundefined
Tool call messages can have no content. -
ContentType[]
Array used in vision and audio models, where content consists of structured parts (e.g., text, image URLs).
ContentType Object
interface ContentType { type: string; text?: string | undefined; image_url?: | { url: string; detail?: string | undefined; } | undefined; };
-
- Name
tool_call_id
- Type
- string
- Description
The id of the called LLM tool if the role is
tool
- Name
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
Variable Object
interface Variable { name: string; value: string; }
- Name
name
- Type
- string
- Required
- Required
- Description
The name of the variable
- Name
value
- Type
- string
- Required
- Required
- 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/v1/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 … : … … …