Pipe: Create v1
The create
pipe API endpoint allows you to create a new pipe on Langbase dynamically with API. You can use this endpoint to create a new pipe with all the custom configuration. This endpoint requires a User or Org API key. To generate a User or Org API key visit your profile/organization settings page on Langbase.
Generate a User/Org API key
You will need to generate an API key to authenticate your requests. For more information, visit the User/Org API key documentation.
Create a new pipe
Create a new pipe by sending the pipe configuration inside the 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
<YOUR_API_KEY>
with your user/org API key.
Body Parameters
- Name
name
- Type
- string
- Required
- Required
- Description
Name of the pipe.
- Name
upsert
- Type
- boolean
- Description
Upsert pipe.
Default:
false
- Name
description
- Type
- array
- Description
Short description of the pipe.
Default:
''
- Name
status
- Type
- string
- Description
Status of the pipe.
Default:
public
Can be one of:
public
,private
- Name
model
- Type
- string
- Description
Pipe LLM model. This is a combination of model provider and model id.
Format:
provider:model_id
You can copy the ID of a model from the list of supported LLM models at Langbase.
Default:
openai:gpt-4o-mini
- Name
stream
- Type
- boolean
- Description
If enabled, the output will be streamed in real-time like ChatGPT. This is helpful if user is directly reading the text.
Default:
true
- Name
json
- Type
- boolean
- Description
Enforce the output to be in JSON format.
Default:
false
- Name
store
- Type
- boolean
- Description
If enabled, both prompt and completions will be stored in the database. Otherwise, only system prompt and few shot messages will be saved.
Default:
true
- Name
moderate
- Type
- boolean
- Description
If enabled, Langbase blocks flagged requests automatically.
Default:
false
- Name
top_p
- Type
- number
- Description
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
Default:
1
- Name
max_tokens
- Type
- number
- Description
Maximum number of tokens in the response message returned.
Default:
1000
- Name
temperature
- Type
- number
- Description
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random. Lower values like 0.2 will make it more focused and deterministic.
Default:
0.7
- Name
presence_penalty
- Type
- number
- Description
Penalizes a word based on its occurrence in the input text.
Default:
1
- Name
frequency_penalty
- Type
- number
- Description
Penalizes a word based on how frequently it appears in the training data.
Default:
1
- Name
stop
- Type
- array
- Description
Up to 4 sequences where the API will stop generating further tokens.
Default:
[]
- Name
tool_choice
- Type
- 'auto' | 'required' | 'object'
- Description
Controls which (if any) tool is called by the model.
auto
- the model can pick between generating a message or calling one or more tools.required
- the model must call one or more tools.object
- Specifying a particular tool via{"type": "function", "function": {"name": "my_function"}}
forces the model to call that tool.
Default:
auto
- Name
parallel_tool_calls
- Type
- boolean
- Description
Call multiple tools in parallel, allowing the effects and results of these function calls to be resolved in parallel.
Default:
true
- Name
messages
- Type
- Array<Message>
- Description
An array containing message objects.
Default:
[]
Message Object
interface Message { role: 'user' | 'assistant' | 'system'| 'tool'; content: string; name?: 'json' | 'safety' | 'opening' | 'rag'; }
- Name
role
- Type
- 'user' | 'assistant' | 'system'| 'tool'
- Description
The role of the author of this message.
- Name
content
- Type
- string
- Description
The contents of the message.
- Name
name
- Type
- 'json' | 'safety' | 'opening' | 'rag'
- Description
The name of the
system
message type.
- Name
variables
- Type
- Array<Variable>
- Description
An array containing different variable objects.
Default:
[]
Variable Object
interface Variable { name: string; value: string; }
- Name
name
- Type
- string
- Description
The name of the variable.
- Name
value
- Type
- string
- Description
The value of the variable.
- Name
tools
- Type
- Array<Tool>
- Description
An array of objects with valid tool definitions.
Read more about valid tool definition
Default:
[]
- Name
memory
- Type
- Array<Memory>
- Description
An array of memory objects.
Default:
[]
Memory Object
interface Memory { name: string; }
- Name
name
- Type
- string
- Description
The name of the memory.
Basic Pipe
import {Langbase} from 'langbase';
const langbase = new Langbase({
apiKey: '<YOUR_API_KEY>', // Replace with your API key
});
const response = await langbase.pipe.create({
name: 'summary-agent',
description: 'A simple pipe example',
});
Response
- Name
Pipe
- Type
- object
- Description
The response object returned by the API endpoint.
Pipe create response
interface Pipe { name: string; description: string; status: 'public' | 'private'; owner_login: string; url: string; type: 'chat' | 'generate' | 'run'; api_key: string; }
- Name
name
- Type
- string
- Description
Name of the pipe.
- Name
description
- Type
- string
- Description
Description of the pipe.
- Name
status
- Type
- 'public' | 'private'
- Description
Pipe visibility status.
- Name
owner_login
- Type
- string
- Description
Login of the pipe owner.
- Name
url
- Type
- string
- Description
Pipe studio URL.
- Name
type
- Type
- 'chat' | 'generate' | 'run'
- Description
The type of the pipe.
- Name
api_key
- Type
- string
- Description
API key for pipe access.
API Response
{
"name": "summary-agent",
"description": "AI pipe for summarization",
"status": "public",
"owner_login": "user123",
"url": "https://langbase.com/user123/summary-agent",
"type": "run",
"api_key": "pipe_4FVBn2DgrzfJf..."
}