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

# SambaNova SDK for Python and JavaScript

> Use the SambaNova SDK to interact with the Infercom API in Python and JavaScript. Type-safe, sync and async support, built-in error handling.

SambaNova offers SDKs for both Python and JavaScript/TypeScript, making it easy to interact with the Infercom REST API. The [SambaNova Python client](https://pypi.org/project/sambanova/) works with Python 3.8 and above, while the [JavaScript/TypeScript version](https://www.npmjs.com/package/sambanova) is designed for server-side environments. Both libraries come with built-in type definitions for request parameters and response fields, and support both synchronous and asynchronous usage.

## Usage example

To get started, select your preferred programming language. Then, open a terminal window and install the SambaNova SDK.

<Tabs syncKey="code">
<TabItem label="Javascript">

```javascript
//ensure you have Node.js installed.
npm install sambanova
```

</TabItem>
<TabItem label="Python">

```python
# make sure you have Python3 and pip installed
pip install sambanova 
```

</TabItem>
</Tabs>

Next, copy the following code into a  new file.

<Tabs syncKey="code">
<TabItem label="hello-world.js">

```javascript
import SambaNova from "sambanova";

const client = new SambaNova({
  baseURL: "https://api.infercom.ai/v1",
  apiKey: "your-infercom-api-key",
});

const chatCompletion = await client.chat.completions.create({
  messages: [
    { role: "system", content: "Answer the question in a couple sentences." },
    { role: "user", content: "Share a happy story with me" },
  ],
  model: "gpt-oss-120b",
});

console.log(chatCompletion.choices[0].message.content);
```

</TabItem>
<TabItem label="hello_world.py">

```python
from sambanova import SambaNova

client = SambaNova(
    base_url="https://api.infercom.ai/v1",
    api_key="your-infercom-api-key"
)

completion = client.chat.completions.create(
  model="gpt-oss-120b",
  messages = [
      {"role": "system", "content": "Answer the question in a couple sentences."},
      {"role": "user", "content": "Share a happy story with me"}
    ]
)

print(completion.choices[0].message.content)
```

</TabItem>
</Tabs>

Once copied into the file, replace the placeholder `"your-infercom-api-key"` with your API key. Then run the file with the command below in a terminal window.

<Tabs syncKey="code">
<TabItem label="Javascript">

```javascript
node hello-world.js
```

</TabItem>
<TabItem label="Python">

```python
python hello_world.py
```

</TabItem>
</Tabs>

After you run the program, you should now see an output like similar to the one below.

```json
{
  "id": "d89243f2-de68-416f-85c6-27c244cf9c7f",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "One day, a little girl named Sophie found a lost puppy in her neighborhood and decided to take care of it until she could find its owner. As she cared for the puppy, named Max, they formed an unbreakable bond, and when the owner was finally found, they were so grateful to Sophie that they asked her to be Max's permanent dog-sitter, bringing joy and companionship to Sophie's life.",
        "role": "assistant"
      },
      "logprobs": null
    }
  ],
  "created": 1759518870.892972,
  "model": "gpt-oss-120b",
  "object": "chat.completion",
  "system_fingerprint": "fastcoe",
  "usage": {
    "completion_tokens": 84,
    "prompt_tokens": 49,
    "total_tokens": 133,
    ...
    "stop_reason": "stop"
  }
}
```
