# Support for Vercel's ai-sdk

**URL:** <https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476>\
**Category:** Hackathons\
**Tags:** dev\
**Created:** [October 24, 2024, 9:41am UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476 "2024-10-24T09:41:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![notagodzilla](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/notagodzilla/32/846_2.png) [@notagodzilla](https://community.sambanova.ai/u/notagodzilla)\
**Post date:** [October 24, 2024, 9:41am UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/1 "2024-10-24T09:41:25Z")

</div>

Vercel launched ai sdk which is a wrapper on top of the existing openai package. Can we use that for building our hackathon submission? I have tested out SambaNova endpoint and it works well with it, just wanted to clarify if the usage is limited to the openai sdk

Vercel AI SDK - [ai - npm](https://www.npmjs.com/package/ai)

---

<div class="post-metadata">

**Author:** ![devnull](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/devnull/32/1864_2.png) [@devnull](https://community.sambanova.ai/u/devnull)\
**Post date:** [January 30, 2025, 8:06pm UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/2 "2025-01-30T20:06:53Z")

</div>

This seems an essential to have to get more adoption

---

<div class="post-metadata">

**Author:** ![Coby](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/coby/32/17_2.png) [@Coby](https://community.sambanova.ai/u/Coby)\
**Post date:** [January 30, 2025, 8:08pm UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/3 "2025-01-30T20:08:22Z")

</div>

Not sure why this never got replied to but the answer is yes you can use this.  
-Coby

---

<div class="post-metadata">

**Author:** ![devnull](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/devnull/32/1864_2.png) [@devnull](https://community.sambanova.ai/u/devnull)\
**Post date:** [January 30, 2025, 8:15pm UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/4 "2025-01-30T20:15:06Z")

</div>

OpenAPI with base URL changes works for basic REST calls, but dedicated AI SDKs provide critical features like proper typing, streaming support, specialized error handling, and helper utilities that you’d otherwise need to build yourself.

---

<div class="post-metadata">

**Author:** ![vasanth.mohan](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/vasanth.mohan/32/16_2.png) [@vasanth.mohan](https://community.sambanova.ai/u/vasanth.mohan)\
**Post date:** [April 1, 2025, 12:50am UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/5 "2025-04-01T00:50:03Z")

</div>

Took a while but it happened: [SambaNova provider for Vercel AI SDK](https://community.sambanova.ai/t/sambanova-provider-for-vercel-ai-sdk/1014)

---

<div class="post-metadata">

**Author:** ![daniel.campagnoli](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/daniel.campagnoli/32/1928_2.png) [@daniel.campagnoli](https://community.sambanova.ai/u/daniel.campagnoli)\
**Post date:** [April 1, 2025, 7:13am UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/6 "2025-04-01T07:13:48Z")

</div>

That’s good news, I’ve added support for SambaNova now to [https://typedai.dev](https://typedai.dev) using the vercel ai package.

---

<div class="post-metadata">

**Author:** ![Shubham.Mishra](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/shubham.mishra/32/1980_2.png) [@Shubham.Mishra](https://community.sambanova.ai/u/Shubham.Mishra)\
**Post date:** [April 28, 2025, 3:39pm UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/7 "2025-04-28T15:39:52Z")

</div>

### Description

We’re using the Vercel AI SDK with SambaNova and streamText method. When calling streamText with DeepSeek model, we’re getting NaN values for token usage in onFinish callback.

Here’s the code we’re using:

```js
const result = streamText({
    model,
    messages,
    onFinish({ usage }) {
      console.log(usage)
    }
  })

```

The output looks like this:

```js
{ promptTokens: NaN, completionTokens: NaN, totalTokens: NaN }

```

We expected to see valid token usage values. Any insights into why this is happening?

---

<div class="post-metadata">

**Author:** ![Shubham.Mishra](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/shubham.mishra/32/1980_2.png) [@Shubham.Mishra](https://community.sambanova.ai/u/Shubham.Mishra)\
**Post date:** [April 28, 2025, 7:07pm UTC](https://community.sambanova.ai/t/support-for-vercels-ai-sdk/476/8 "2025-04-28T19:07:19Z")

</div>

Okay I found the issue and fixed it. I have requested PR in github.

> <https://github.com/sambanova/sambanova-ai-provider/pull/15>
>
> \## Short description
> Fixes an issue where SambaNova streaming responses were re…turning \`{ promptTokens: NaN, completionTokens: NaN, totalTokens: NaN }\` in the \`onFinish\` callback when using the Vercel AI SDK.  
> This PR ensures correct token usage tracking during streaming by including \`stream\_options: { include\_usage: true }\` in the request payload.
> 
> \## Additions, changes, and/or deletions
> \- Modified \`doStream\` to add \`stream\_options: { include\_usage: true }\` when initiating the \`/chat/completions\` streaming request.
> \- Preserved existing behavior for other models and providers.
> 
> \## Issue(s) this PR Closes
> (https://github.com/sambanova/sambanova-ai-provider/issues/14)
