# Chat

{% tabs %}
{% tab title="NodeJS (TS)" %}

```typescript
import PropulsionAI from 'propulsionai';
import {
  ModelChatResponse,
  ModelChatParams
} from 'propulsionai/resources/models';

const p8n = new PropulsionAI({
  bearerToken: process.env['PROPULSIONAI_BEARER_TOKEN'] as string,
});

async function main() {
  try {
    let deployment_tag: string = '<deployment_tag>';
    let params: ModelChatParams = {
      messages: [
        {
          role: 'system',
          content: "You are an amazing poet.",
        },
        {
          role: 'user',
          content: "Can you write a poem about Tesla, the innovator?",
        },
      ],
      model: 'auto',
      stream: false,
      wait: true,
    };
    let response: ModelChatResponse;
    try{
      response = await p8n.models.ep(deployment_tag, params);
    }catch(e){
      console.log('Error:', e);
      return;
    }
    console.log("Task ID:", response.task_id);
    if(response.choices) {
      response.choices.forEach((choice) => {
        console.log(`${choice.message?.role}: ${choice.message?.content}`);
      });
    }
  } catch (error) {
    console.error('Error during model call:', error);
  }
}

main();

```

{% endtab %}

{% tab title="NodeJS (JS)" %}

```javascript
import PropulsionAI from 'propulsionai';

const p8n = new PropulsionAI({
  bearerToken: process.env['PROPULSIONAI_BEARER_TOKEN'],
});

async function main() {
  try {
    let deployment_tag = '<deployment_tag>';
    let params = {
      messages: [
        {
          role: 'system',
          content: "You are an amazing poet.",
        },
        {
          role: 'user',
          content: "Can you write a poem about Tesla, the innovator?",
        },
      ],
      model: 'auto',
      stream: false,
      wait: true,
    };
    let response;
    try{
      response = await p8n.models.ep(deployment_tag, params);
    }catch(e){
      console.log('Error:', e);
      return;
    }
    console.log("Task ID:", response.task_id);
    if(response.choices) {
      response.choices.forEach((choice) => {
        console.log(`${choice.message?.role}: ${choice.message?.content}`);
      });
    }
  } catch (error) {
    console.error('Error during model call:', error);
  }
}

main();
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from propulsionai import AsyncPropulsionAI
from propulsionai.models import ModelChatResponse

# Initialize AsyncPropulsionAI with bearer token from environment variables
p8n = AsyncPropulsionAI(
    bearer_token=os.environ.get("PROPULSIONAI_BEARER_TOKEN"),
)

async def main() -> None:
    try:
        response: ModelChatResponse = await p8n.models.ep(
            '<deployment_tag>',
            messages=[
                {
                    "role": "system",
                    "content": "You are an amazing poet.",
                },
                {
                    "role": 'user',
                    "content": "Can you write a poem about Tesla, the innovator?",
                },
            ],
            model="auto",
            stream=False,
            wait=True,
        )
        print(response.id)
        print(response.content)
    except Exception as e:
        print(f"Error during model call: {e}")

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

```

{% endtab %}

{% tab title="cURL" %}

```bash
# Inference Call
curl -X "POST" "https://api.propulsionhq.com/api/v1/chat/<deployment_tag>?wait=true" \
     -H 'Authorization: Bearer <PROPULSIONAI_BEARER_TOKEN>' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "messages": [
    {
      "role": "system",
      "content": "You are an amazing poet."
    },
    {
      "role": "user",
      "content": "Can you write a poem about Tesla, the innovator?"
    }
  ],
  "model": "auto",
}'
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.propulsionhq.com/developer-guide/chat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
