---
title: "POST /{workspace}/{project}/{prompt}/{environment}"
method: POST
path: "/{workspace}/{project}/{prompt}/{environment}"
---

# POST /{workspace}/{project}/{prompt}/{environment}

`POST /{workspace}/{project}/{prompt}/{environment}`

## Request

- Base URL: `https://api.langtail.com`
- URL: `https://api.langtail.com/{workspace}/{project}/{prompt}/{environment}`
- Auth: none declared. Required headers: `X-API-Key`

Get completion for stored prompt. The response format is the same as [OpenAI Chat completion response](https://platform.openai.com/docs/api-reference/chat/object).

## Path parameters

- `workspace` string, required
- `project` string, required
- `prompt` string, required
- `environment` string, required

## Headers

- `X-API-Key` string, required

## Request body

- object
  - `variables` object: A mapping of variable names to their values. Will be injected in your saved prompt template.
  - `messages` object[]: Additional messages. These will be appended to the Prompt Template.
    - `role` 'assistant' | 'user' | 'system' | 'function' | 'tool', required
    - `name` string
    - `content` union, required
      - string: Text content
      - union[]: Mix of text and images.
        - union
          - object
            - `type` 'text', required
            - `text` string, required
          - object
            - `type` 'image_url', required
            - `image_url` object, required
              - …
      - unknown
    - `function_call` object
      - `name` string, required
      - `arguments` string, required
    - `tool_calls` object[]
      - `id` string, required
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
        - `arguments` string, required
    - `tool_choice` union
      - 'auto'
      - 'none'
      - object
        - `type` 'function', required
        - `function` object, required
          - `name` string, required
    - `tool_call_id` string
  - `stream` boolean
  - `model` string: Overrides the model of deployed prompt.
  - `max_tokens` number: Overrides the max tokens of deployed prompt. The maximum number of tokens that can be generated in the completion.
  - `temperature` number: Overrides the temperature of deployed prompt. 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_p` number: Overrides the top_p of deployed prompt. 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_penalty` number: Overrides the presence_penalty of deployed prompt.
  - `frequency_penalty` number: Overrides the frequency_penalty of deployed prompt.
  - `template` object[]: Overrides the stored template messages with custom template messages.
    - `role` 'assistant' | 'user' | 'system' | 'function' | 'tool', required
    - `name` string
    - `content` union, required
      - string: Text content
      - union[]: Mix of text and images.
        - union
          - object
            - `type` 'text', required
            - `text` string, required
          - object
            - `type` 'image_url', required
            - `image_url` object, required
              - …
      - unknown
    - `function_call` object
      - `name` string, required
      - `arguments` string, required
    - `tool_calls` object[]
      - `id` string, required
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
        - `arguments` string, required
    - `tool_choice` union
      - 'auto'
      - 'none'
      - object
        - `type` 'function', required
        - `function` object, required
          - `name` string, required
    - `tool_call_id` string
  - `tool_choice` union: Overrides the tool choice of deployed prompt.
    - 'auto' | 'required' | 'none'
    - object
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
  - `response_format` object: Overrides the response format of deployed prompt.
    - `type` 'json_object', required
  - `user` string: A unique identifier representing your end-user
  - `doNotRecord` boolean: If true, potentially sensitive data like the prompt and response will not be recorded in the logs
  - `metadata` object: Additional custom data that will be stored for this request
  - `seed` number: A seed is used to generate reproducible results

## Response `200`

Chat completion response from OpenAI - see https://platform.openai.com/docs/api-reference/chat/object for more details.

- object
  - `id` string, required: A unique identifier for the chat completion.
  - `object` string, required: The object type, which is always `chat.completion`.
  - `created` number, required: The Unix timestamp (in seconds) of when the chat completion was created.
  - `model` string, required: The model used for the chat completion.
  - `choices` object[], required: A list of chat completion choices. Can be more than one if `n` is greater than 1.
    - `index` 0, required: The index of the choice in the list of choices.
    - `message` object, required
      - `role` 'assistant', required: The role of the author of this message.
      - `content` string, nullable, required
    - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call', required: The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.

## Other responses

- `400`: Invalid request bodys

---

[API](https://skmtc.dev/langtail/apis/langtail-prompt-endpoint.md) - [All operations](https://skmtc.dev/langtail/apis/langtail-prompt-endpoint/llms.txt) - [OpenAPI document](https://skmtc.dev/langtail/apis/langtail-prompt-endpoint/revisions/7186c80b2e39?raw)
