> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompts

> SDK methods to create, list, retrieve, and manage prompts in the TrueFoundry prompt registry.

## Methods

<Accordion title="get">
  Get a prompt by its ID.

  #### Parameters

  <ParamField body="id" type="str" required />

  #### Returns

  <ResponseField name="GetPromptResponse" type="GetPromptResponse">
    [🔗 GetPromptResponse](/docs/truefoundry_sdk/types#getpromptresponse)

    The prompt data
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.prompts.get(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="delete">
  Delete a prompt by its ID.

  #### Parameters

  <ParamField body="id" type="str" required />

  #### Returns

  <ResponseField name="EmptyResponse" type="EmptyResponse">
    [🔗 EmptyResponse](/docs/truefoundry_sdk/types#emptyresponse)

    Empty response indicating successful deletion
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.prompts.delete(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="list">
  List prompts with optional filtering by FQN, ML Repo, or name.

  #### Parameters

  <ParamField body="fqn" type="typing.Optional[str]">
    Fully qualified name to filter prompts by (format: 'chat\_prompt:{tenant_name}/{ml_repo_name}/{prompt_name}')
  </ParamField>

  <ParamField body="ml_repo_id" type="typing.Optional[str]">
    ID of the ML Repo to filter prompts by
  </ParamField>

  <ParamField body="name" type="typing.Optional[str]">
    Name of the prompt to filter by
  </ParamField>

  <ParamField body="offset" type="typing.Optional[int]">
    Number of prompts to skip for pagination
  </ParamField>

  <ParamField body="limit" type="typing.Optional[int]">
    Maximum number of prompts to return
  </ParamField>

  <ParamField body="include_empty_prompts" type="typing.Optional[bool]">
    Whether to include prompts that have no versions
  </ParamField>

  #### Returns

  <ResponseField name="SyncPager[Prompt, ListPromptsResponse]" type="SyncPager[Prompt, ListPromptsResponse]">
    [🔗 ListPromptsResponse](/docs/truefoundry_sdk/types#listpromptsresponse)

    List of prompts matching the query with pagination information
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.prompts.list(
      fqn="value",
      ml_repo_id="value",
      name="value",
      offset=10,
      limit=10,
      include_empty_prompts="value",
  )

  # Iterate through results
  for item in response:
      print(item.name)

  # Or paginate page by page
  for page in response.iter_pages():
      for item in page:
          print(item.name)
  ```
</Accordion>

<Accordion title="create_or_update">
  Create or update a prompt version.

  #### Parameters

  <ParamField body="manifest" type="ChatPromptManifest" required>
    [🔗 ChatPromptManifest](/docs/truefoundry_sdk/types#chatpromptmanifest)

    Manifest containing metadata for the prompt to apply
  </ParamField>

  #### Returns

  <ResponseField name="GetPromptVersionResponse" type="GetPromptVersionResponse">
    [🔗 GetPromptVersionResponse](/docs/truefoundry_sdk/types#getpromptversionresponse)

    The created or updated prompt version
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.prompts.create_or_update(
      manifest={"key": "value"},
  )
  ```
</Accordion>

<Accordion title="get_by_fqn">
  Get Prompt by FQN.

  #### Parameters

  <ParamField body="fqn" type="str" required>
    FQN of the prompt
  </ParamField>

  #### Returns

  <ResponseField name="GetPromptResponse" type="GetPromptResponse">
    [🔗 GetPromptResponse](/docs/truefoundry_sdk/types#getpromptresponse)

    Prompt details
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.prompts.get_by_fqn(
      fqn="value",
  )
  ```
</Accordion>
