https://github.com/github/models-ai-sdk
GitHub Models AI SDK
https://github.com/github/models-ai-sdk
ai github-models sdk
Last synced: 5 months ago
JSON representation
GitHub Models AI SDK
- Host: GitHub
- URL: https://github.com/github/models-ai-sdk
- Owner: github
- License: mit
- Created: 2025-07-07T07:33:35.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-08-25T20:34:31.000Z (6 months ago)
- Last Synced: 2025-08-25T23:46:10.944Z (5 months ago)
- Topics: ai, github-models, sdk
- Language: TypeScript
- Homepage: https://npmjs.com/@github/models
- Size: 130 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Contributing: contributing.md
- License: license.txt
- Code of conduct: code_of_conduct.md
- Codeowners: .github/CODEOWNERS
- Security: security.md
- Support: support.md
Awesome Lists containing this project
README
# AI SDK - GitHub Models
The GitHub Models provider for the [AI SDK](https://ai-sdk.dev/docs) gives you access to the [GitHub Models][feature] catalog of large language models, designed for building modern web applications.
GitHub Models has support for multiple model families, like [xAI](https://github.com/marketplace?publisher=xAI&type=models), [OpenAI](https://github.com/marketplace?publisher=OpenAI&type=models) and [Meta](https://github.com/marketplace?publisher=Meta&type=models).
> [!IMPORTANT]
> GitHub Models is currently in pre-release and subject to [GitHub Pre-release License Terms](https://docs.github.com/en/site-policy/github-terms/github-pre-release-license-terms).
To learn more about integrating GitHub Models into your projects, visit the [GitHub Models documentation](https://docs.github.com/en/github-models).
## Setup
The GitHub Models provider is available in the `@github/models` NPM package. You can install it with:
```bash
npm i @github/models
```
## Quick Start
To get started, you'll need a [GitHub PAT (personal access token)](https://github.com/settings/tokens).
```ts
import {githubModels} from '@github/models'
import {generateText} from 'ai'
const result = await generateText({
model: githubModels('meta/meta-llama-3.1-8b-instruct'),
prompt: 'Write a haiku about programming.',
})
console.log(result.text)
```
> [!TIP]
> GitHub Models includes [free usage](https://gh.io/models-rate-limits) for all accounts. For higher usage limits, you can opt into [paid usage](https://gh.io/github-models-pricing).
If you need a customized setup, you can import `createGithubModels` from `@github/models` and create a provider instance with your settings:
```ts
import {createGithubModels} from '@github/models'
const githubModels = createGithubModels({
org: 'my-organization',
})
```
### Configuration Options
- **apiKey** _string_
Your GitHub [Personal Access Token](https://github.com/settings/tokens) or [Fine-Grained Token](https://github.com/settings/personal-access-tokens) with `read:models` scope.
Defaults to the `GITHUB_TOKEN` environment variable.
- **org** _string_
Organization to attribute API usage to (optional).
- **baseURL** _string_
Custom API endpoint URL.
Defaults to `https://models.github.ai/inference`.
- **headers** _Record_
Additional headers to include with requests.
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise_
Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
Defaults to the global `fetch` function.
You can use it as a middleware to intercept requests,
or to provide a custom fetch implementation for e.g. testing.
## Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of GitHub's trademarks or logos is subject to and must follow [GitHub's Brand Toolkit](https://brand.github.com/). Use of GitHub's trademarks or logos in modified versions of this project must not cause confusion or imply GitHub sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
## License
Distributed under the MIT License. See [LICENSE](./license.txt) for more information.
[feature]: https://github.com/features/models