# Using the SDK

{% content-ref url="/pages/tMRAxvFbmCHMdkBxiTVa" %}
[Installing the SDK](/introduction/installing-the-sdk.md)
{% endcontent-ref %}

{% content-ref url="/pages/Q1ohPTL0YpFjBsfGED5v" %}
[Generate API Key](/quick-start/generate-api-key.md)
{% endcontent-ref %}

**Initialize the client**

{% tabs %}
{% tab title="Typescript" %}

```
import PropulsionAI from 'propulsionai';

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

{% endtab %}

{% tab title="Python" %}

```python
from propulsionai import PropulsionAI

client = PropulsionAI(
    # This is the default and can be omitted
    bearer_token=os.environ.get("PROPULSIONAI_BEARER_TOKEN"),
)
```

{% endtab %}
{% endtabs %}

Chat

{% tabs %}
{% tab title="Typescript" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>async function main() {
</strong>    const completionCreateResponse = await client.chat.completions.create({
        deployment: '&#x3C;deployment_id>',
        messages=[
            {
                "role": "user",
                "content": "Hello, How are you?",
            }
        ],
        stream: false
    });
    
    console.log(completionCreateResponse.choices);
}
main();
</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
def sync_main() -> None:
    response = client.chat.completions.create(
        deployment="<deployment_id>",
        messages=[
            {
                "role": "user",
                "content": "Hello, How are you?",
            }
        ],
        stream=False,
    )

    print(response)

sync_main()
```

{% endtab %}
{% endtabs %}

Streaming Chat

{% tabs %}
{% tab title="Typescript" %}

```python
async function main() {
    const completionCreateResponse = await client.chat.completions.create({
        deployment: '<deployment_id>',
        messages=[
            {
                "role": "user",
                "content": "Hello, How are you?",
            }
        ],
        stream: true
    });
    
    for await (const part of stream) {
        process.stdout.write(part.choices[0]?.delta?.content || '');
    }
}
main();
```

{% endtab %}

{% tab title="Python" %}

```
def sync_main() -> None:
    response = client.chat.completions.create(
        deployment="<deployment_id>",
        messages=[
            {
                "role": "user",
                "content": "Hello, How are you?",
            }
        ],
        stream=True,
    )

    for data in response:
      if data:
          chunk = data.to_json()
          chunk_json = json.loads(chunk)
          
          if chunk_json["choices"] and chunk_json["choices"][0]["delta"] is not None:
              delta = chunk_json["choices"][0]["delta"]
              if "content" in delta and delta["content"] is not None:
                  sys.stdout.write(delta["content"])
                  sys.stdout.flush() # Ensure content is displayed immediately

sync_main()
```

{% 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/quick-start/using-the-sdk.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.
