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.


POST/v1/pipes

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

POST
/v1/pipes
curl https://api.langbase.com/v1/pipes \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-d '{
  "name": "test-pipe",
  "upsert": true,
  "description": "This is a test pipe",
  "status": "public",
  "model": "openai:gpt-4o-mini"
}'

Response

{
  "name": "test-pipe",
  "type": "chat",
  "description": "This is a create Pipe test from API",
  "status": "private",
  "api_key": "pipe_4FVBn2DgrzfJf...",
  "owner_login": "langbase",
  "url": "https://langbase.com/langbase/test-pipe"
}