> ## Documentation Index
> Fetch the complete documentation index at: https://docs-v1.latitude.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Run prompt

> Learn how to run a prompt with the Latitude SDK

## Prompt

<CodeGroup>
  ```markdown example theme={null}
  ---
  provider: Latitude
  model: gpt-4o-mini
  temperature: 0.7
  ---

  <system>
  You are a creative assistant that crafts engaging product descriptions.
  </system>
  <user>
  Write a compelling product description for {{product_name}} highlighting its features: {{features}}.
  The description should appeal to {{target_audience}} and have a {{tone}} tone.

  IMPORTANT: The name of the product should not be altered or added anything. Ex.: "Ford" as product_name should not be "ford-card".

  Limit the description to {{word_count}} words although if you produce + or - 10 words over under this limit is fine.
  </user>
  ```
</CodeGroup>

## Code

See the code below for how to run a prompt using the Latitude SDK.

<CodeGroup>
  ```typescript Typescript theme={null}
  import { Latitude } from '@latitude-data/sdk'

  async function run() {
    const sdk = new Latitude(process.env.LATITUDE_API_KEY, {
      projectId: Number(process.env.PROJECT_ID),
      versionUuid: 'live',
      __internal: {
        gateway: {
          host: 'localhost',
          port: 8787,
          ssl: false,
        }
      },
    })

    const result = await sdk.prompts.run('onboarding', {
      // Get messages as streaming
      stream: false,
      background: false,
      parameters: {
        phrase: 'I get a very good feeling about this new project.',
      },

      // To get streaming you can use `onEvent`
      onEvent: (event) => {
        console.log('Event:', event)
      },
      onError: (error) => {
        if (!error) return

        console.error('Error:', error)
      },
    })

    console.log('Result:', result)
  }

  run()
  ```

  ```python Python theme={null}
  import asyncio
  import os

  from latitude_sdk import ApiError, FinishedResult, Latitude, LatitudeOptions, RunPromptOptions, StreamEvent


  async def on_event(event: StreamEvent):
      print(event, "\n" * 2)


  async def on_finished(result: FinishedResult):
      print(result, "\n" * 2)


  async def on_error(error: ApiError):
      print(error, "\n" * 2)


  async def run():
      api_key = os.getenv("LATITUDE_API_KEY")
      sdk_options = LatitudeOptions(
          project_id=int(os.getenv("PROJECT_ID")),
          version_uuid="live",
      )
      sdk = Latitude(api_key, sdk_options)
      result = await sdk.prompts.run(
          "run-prompt/example",
          RunPromptOptions(
              parameters={
                  "product_name": "iPhone",
                  "features": "Camera, Battery, Display",
                  "target_audience": "Tech enthusiasts",
                  "tone": "Informal",
                  "word_count": 20,
              },
              on_event=on_event,
              on_finished=on_finished,
              on_error=on_error,
              stream=True,
          ),
      )

      if result:
          print(result.response.text, "\n" * 2)


  asyncio.run(run())
  ```
</CodeGroup>
