https://github.com/wireless25/nscale-ai-provider
https://github.com/wireless25/nscale-ai-provider
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/wireless25/nscale-ai-provider
- Owner: wireless25
- Created: 2025-09-12T15:11:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-12T15:38:00.000Z (10 months ago)
- Last Synced: 2025-09-12T18:03:37.673Z (10 months ago)
- Language: TypeScript
- Size: 63.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# AI SDK - nscale Provider
> the project is under active development, for now only text models are supported.
The Nscale provider for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Nscale Serverless Inference Models](https://www.nscale.com/product/serverless).
## Setup
The Nscale provider is available in the `nscale-ai-provider` module. You can install it with
```bash
npm i nscale-ai-provider
```
## Provider Instance
You can import the default provider instance `nscale` from `nscale-ai-provider`:
```ts
import { nscale } from 'nscale-ai-provider'
```
## Example
```ts
import { generateText } from 'ai'
import { nscale } from 'nscale-ai-provider'
const { text } = await generateText({
model: nscale('openai/gpt-oss-20b'),
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
})
```
For this to work you need the `NSCALE_API_KEY` environment variable set with your Nscale Service Token.
Alternatively create a instance of the provider:
```ts
import { generateText } from 'ai'
import { createNscale } from 'nscale-ai-provider'
const nscale = createNscale({
apiKey: '', // Nscale Service Token
})
const { text } = await generateText({
model: nscale('openai/gpt-oss-20b'),
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
})
```
## Nscale Client Hook
To get data about the Nscale models, you can use the `useNscaleModels` hook:
```tsx
import type { NscaleModel } from 'nscale-ai-provider/client'
import { useNscaleModels } from 'nscale-ai-provider/client'
interface ModelSelectProps {
selectedModelId?: string
onChange: (modelId: string) => void
}
function ChatModelSelect({ selectedModelId, onChange }: ModelSelectProps) {
const { models } = useNscaleModels()
if (!models || models.length === 0) {
return No models available
}
return (
onChange(e.target.value)}
>
Select a model...
{models.map(model => (
{model.name}
))}
)
}
```
You can get `models` from the hook.
### Interface
```ts
interface NscaleModel {
id: string,
contextLength: number,
name: string,
}
function useNscaleModels(): {
models: NscaleModel[]
}
```
## Documentation
Please check out the **[ai-sdk documentation](https://ai-sdk.dev/docs/ai-sdk-core/overview)** for more information.