open-index/open-npm huggingface dataset:
npm package: @khulnasoft/ai-sdk
Description: The KhulnaSoft AI SDK is **a library for building AI-powered streaming text and chat UIs**.
Latest version: 2.2.29

# KhulnaSoft AI SDK

The KhulnaSoft AI SDK is **a library for building AI-powered streaming text and chat UIs**.

## Features

- [SWR](https://swr.vercel.app)-powered React, Svelte, Vue and Solid helpers for streaming text responses and building chat and completion UIs
- First-class support for [LangChain](https://js.langchain.com/docs) and [OpenAI](https://openai.com), [Anthropic](https://www.anthropic.com), [Cohere](https://cohere.com), [Hugging Face](https://huggingface.co), [Fireworks](https://app.fireworks.ai) and [Replicate](https://replicate.com)
- Node.js, Serverless, and [Edge Runtime](https://edge-runtime.vercel.app/) support
- Callbacks for saving completed streaming responses to a database (in the same request)

## Installation

```sh
pnpm install ai
```

View the full documentation and examples on [ai.khulnasoft.com/docs](https://ai.khulnasoft.com/docs)

## Example: An AI Chatbot with Next.js and OpenAI

With the KhulnaSoft AI SDK, you can build a ChatGPT-like app in just a few lines of code:

```tsx
// ./app/api/chat/route.js
import OpenAI from 'openai';
import { OpenAIStream, StreamingTextResponse } from 'ai';

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

export const runtime = 'edge';

export async function POST(req) {
  const { messages } = await req.json();
  const response = await openai.chat.completions.create({
    model: 'gpt-4',
    stream: true,
    messages,
  });
  const stream = OpenAIStream(response);
  return new StreamingTextResponse(stream);
}
```

```tsx
// ./app/page.js
'use client';

import { useChat } from 'ai/react';

export default function Chat() {
  const { messages, input, handleInputChange, handleSubmit } = useChat();

  return (
    <div>
      {messages.map(m => (
        <div key={m.id}>
          {m.role}: {m.content}
        </div>
      ))}

      <form onSubmit={handleSubmit}>
        <input
          value={input}
          placeholder="Say something..."
          onChange={handleInputChange}
        />
      </form>
    </div>
  );
}
```

---

View the full documentation and examples on [ai.khulnasoft.com/docs](https://ai.khulnasoft.com/docs).

## Authors

This library is created by [Vercel](https://vercel.com) and [Next.js](https://nextjs.org) team members, with contributions from:

- Jared Palmer ([@jaredpalmer](https://twitter.com/jaredpalmer)) - [Vercel](https://vercel.com)
- Shu Ding ([@shuding\_](https://twitter.com/shuding_)) - [Vercel](https://vercel.com)
- Max Leiter ([@max_leiter](https://twitter.com/max_leiter)) - [Vercel](https://vercel.com)
- Malte Ubl ([@cramforce](https://twitter.com/cramforce)) - [Vercel](https://vercel.com)
- Justin Ridgewell ([@jridgewell](https://github.com/jridgewell)) - [Vercel](https://vercel.com)

[Contributors](https://github.com/khulnasoft/ai-sdk/graphs/contributors)
npm package: @khulnasoft/anthropic
Description: **Note: The Anthropic API does not support streaming tool calls yet.**
Latest version: 0.0.1

# Vercel AI SDK - Anthropic Provider

**Note: The Anthropic API does not support streaming tool calls yet.**

The Anthropic provider contains language model support for the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_post).
It creates language model objects that can be used with the `generateText` and `streamText`AI functions.

## Setup

The Anthropic provider is available in the `@khulnasoft/anthropic` module. You can install it with

```
npm i @khulnasoft/anthropic
```

## Provider Instance

You can import `Anthropic` from `ai/anthropic` and initialize a provider instance with various settings:

```ts
import { Anthropic } from '@khulnasoft/anthropic';

const anthropic = new Anthropic({
  baseUrl: '', // optional base URL for proxies etc.
  apiKey: '', // optional API key, default to env property ANTHROPIC_API_KEY
});
```

The AI SDK also provides a shorthand `anthropic` import with a Anthropic provider instance that uses defaults:

```ts
import { anthropic } from '@khulnasoft/anthropic';
```

## Messages Models

You can create models that call the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_post) using the `.messages()` factory method.
The first argument is the model id, e.g. `claude-3-haiku-20240307`.
Some models have multi-modal capabilities.

```ts
const model = anthropic.messages('claude-3-haiku-20240307');
```

Anthropic Messages` models support also some model specific settings that are not part of the [standard call settings](/docs/ai-core/settings).
You can pass them as an options argument:

```ts
const model = anthropic.messages('claude-3-haiku-20240307', {
  topK: 0.2,
});
```