POST /{workspace}/{project}/{assistant}/{environment}

Get completion for a stored assistant. This endpoint invokes the assistant and returns its response. It uses chat completions on the backend and maintains OpenAI-compatible format. Assistants are stateful AI agents that can leverage various model providers and tools, access persistent conversation threads, and execute multiple tools in parallel.

Request

  • Base URL
    https://api.langtail.com
  • Auth
    none declared. Required headers: X-API-Key

Path parameters

workspacestring required
Example:workspace

Your workspace URL slug

projectstring required
Example:project

Your project URL slug

assistantstring required
Example:assistant

Your assistant URL slug

environmentstring required
Example:production

Your environment URL slug

Headers

X-API-Keystring required
Example:<LANGTAIL_API_KEY>

Your Langtail API Key

Request body

threadIdstring

A unique identifier for the thread. If not provided, a new thread will be created.

variablesobject

A mapping of variable names to their values. Will be injected in your saved assistant template.

streamboolean
modelstring

Overrides the model of deployed assistant.

max_tokensnumber

Overrides the max tokens of deployed assistant. The maximum number of tokens that can be generated in the completion.

temperaturenumber

Overrides the temperature of deployed assistant. What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

top_pnumber

Overrides the top_p of deployed assistant. 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. We generally recommend altering this or temperature but not both.

presence_penaltynumber

Overrides the presence_penalty of deployed assistant.

frequency_penaltynumber

Overrides the frequency_penalty of deployed assistant.

userstring

A unique identifier representing your end-user

doNotRecordboolean

If true, potentially sensitive data like the assistant and response will not be recorded in the logs

metadataobject

Additional custom data that will be stored for this request

seednumber

A seed is used to generate reproducible results

Example request

{
  "threadId": "thread_123",
  "variables": {
    "variableName": "Your Value"
  },
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "user": "user_123",
  "metadata": {
    "my_identifier": "my-custom-ID"
  },
  "seed": 123
}

Response

Chat completion response from OpenAI - see https://platform.openai.com/docs/api-reference/chat/object for more details. Note: The response includes an 'x-langtail-thread-id' header containing the unique identifier for the thread associated with this response.

idstring required

A unique identifier for the chat completion.

objectstring required

The object type, which is always chat.completion.

creatednumber required

The Unix timestamp (in seconds) of when the chat completion was created.

modelstring required

The model used for the chat completion.

Example response

{
  "choices": [
    {
      "message": {
        "content": "I'm sorry, but I'm not able to fulfill this request."
      }
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.