Skip to content

Commit f7a477b

Browse files
heiskrRonRicardogarmanSiaraMistEbonsignori
authored
GitHub models REST API docs (#55288)
Co-authored-by: Roniece Ricardo <33437850+RonRicardo@users.noreply.github.com> Co-authored-by: Daniel Garman <garman@github.com> Co-authored-by: SiaraMist <siaramist@github.com> Co-authored-by: Evan Bonsignori <ebonsignori@github.com>
1 parent a22ff5c commit f7a477b

19 files changed

Lines changed: 1073 additions & 61 deletions

.github/workflows/sync-openapi.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,23 @@ jobs:
4242
path: rest-api-description
4343
ref: ${{ inputs.SOURCE_BRANCH }}
4444

45+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
46+
with:
47+
# By default, only the most recent commit of the `main` branch
48+
# will be checked out
49+
repository: github/models-gateway
50+
path: models-gateway
51+
4552
- uses: ./.github/actions/node-npm-setup
4653

4754
- name: Sync the REST, Webhooks, and GitHub Apps schemas
4855
env:
4956
# Needed for gh
5057
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
5158
run: |
52-
npm run sync-rest -- --source-repo rest-api-description --output rest github-apps webhooks rest-redirects
59+
npm run sync-rest -- \
60+
--source-repos rest-api-description models-gateway \
61+
--output rest github-apps webhooks rest-redirects
5362
git status
5463
echo "Deleting the cloned github/rest-api-description repo..."
5564
rm -rf rest-api-description

content/rest/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ children:
7373
- /meta
7474
- /metrics
7575
- /migrations
76+
- /models
7677
- /oauth-authorizations
7778
- /orgs
7879
- /packages

content/rest/models/catalog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: REST API endpoints for models catalog
3+
shortTitle: Catalog
4+
intro: Use the REST API to get a list of models available for use, including details like ID, supported input/output modalities, and rate limits.
5+
versions: # DO NOT MANUALLY EDIT. CHANGES WILL BE OVERWRITTEN BY A 🤖
6+
fpt: '*'
7+
topics:
8+
- API
9+
autogenerated: rest
10+
allowTitleToDifferFromFilename: true
11+
---
12+
13+
## About {% data variables.product.prodname_github_models %} catalog
14+
15+
You can use the REST API to explore available models in the {% data variables.product.prodname_github_models %} catalog.
16+
17+
<!-- Content after this section is automatically generated -->

content/rest/models/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Models
3+
topics:
4+
- API
5+
autogenerated: rest
6+
allowTitleToDifferFromFilename: true
7+
children:
8+
- /catalog
9+
- /inference
10+
versions:
11+
fpt: '*'
12+
---

content/rest/models/inference.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: REST API endpoints for models inference
3+
shortTitle: Inference
4+
intro: Use the REST API to submit a chat completion request to a specified model, with or without organizational attribution.
5+
versions: # DO NOT MANUALLY EDIT. CHANGES WILL BE OVERWRITTEN BY A 🤖
6+
fpt: '*'
7+
topics:
8+
- API
9+
autogenerated: rest
10+
allowTitleToDifferFromFilename: true
11+
---
12+
13+
## About {% data variables.product.prodname_github_models %} inference
14+
15+
You can use the REST API to run inference requests using the {% data variables.product.prodname_github_models %} platform.
16+
17+
The API supports:
18+
19+
* Accessing top models from OpenAI, DeepSeek, Microsoft, Llama, and more.
20+
* Running chat-based inference requests with full control over sampling and response parameters.
21+
* Streaming or non-streaming completions.
22+
* Organizational attribution and usage tracking.
23+
24+
<!-- Content after this section is automatically generated -->

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
"cookie-parser": "^1.4.7",
267267
"cuss": "2.2.0",
268268
"dayjs": "^1.11.13",
269+
"dereference-json-schema": "^0.2.1",
269270
"dotenv": "^16.4.7",
270271
"escape-string-regexp": "5.0.0",
271272
"express": "4.21.2",

src/rest/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To run the REST pipeline locally:
3636

3737
1. Clone the [`github/rest-api-description`](https://github.com/github/rest-api-description) repository inside your local `docs-internal` repository.
3838
1. Set a `GITHUB_TOKEN` in your `.env` with (classic) `repo` scopes & enable SSO for the github org.
39-
1. Run `npm run sync-rest -- -s rest-api-description -o rest`. Note, by default `-o rest` is specified, so you can omit it.
39+
1. Run `npm run sync-rest -- -s rest-api-description models-gateway -o rest`. Note, by default `-o rest` is specified, so you can omit it.
4040

4141
## About this directory
4242

src/rest/components/RestCodeSamples.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ export function RestCodeSamples({ operation, slug, heading }: Props) {
7676
// Menu options for the language selector
7777
const languageSelectOptions: CodeSampleKeys[] = [CodeSampleKeys.curl]
7878

79-
// Management Console and GHES Manage API operations are not supported by Octokit
80-
if (operation.subcategory !== 'management-console' && operation.subcategory !== 'manage-ghes') {
79+
// Management Console, GHES Manage API, and GitHub Models
80+
// operations are not supported by Octokit
81+
if (
82+
operation.category !== 'models' &&
83+
operation.subcategory !== 'management-console' &&
84+
operation.subcategory !== 'manage-ghes'
85+
) {
8186
languageSelectOptions.push(CodeSampleKeys.javascript)
8287

8388
// Not all examples support the GH CLI language option. If any of

src/rest/components/RestOperation.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ const DEFAULT_ACCEPT_HEADER = {
2626
isRequired: false,
2727
}
2828

29+
const REQUIRED_CONTENT_TYPE_HEADER = {
30+
name: 'content-type',
31+
type: 'string',
32+
description: `<p>Setting to <code>application/json</code> is required.</p>`,
33+
isRequired: true,
34+
}
35+
2936
export function RestOperation({ operation }: Props) {
3037
const titleSlug = slug(operation.title)
3138
const { t } = useTranslation('rest_reference')
@@ -34,11 +41,13 @@ export function RestOperation({ operation }: Props) {
3441
const headers =
3542
operation.subcategory === 'management-console' || operation.subcategory === 'manage-ghes'
3643
? []
37-
: [DEFAULT_ACCEPT_HEADER]
38-
const numPreviews = operation.previews.length
39-
const hasStatusCodes = operation.statusCodes.length > 0
40-
const hasCodeSamples = operation.codeExamples.length > 0
41-
const hasParameters = operation.parameters.length > 0 || operation.bodyParameters.length > 0
44+
: operation.subcategory === 'inference'
45+
? [REQUIRED_CONTENT_TYPE_HEADER, DEFAULT_ACCEPT_HEADER]
46+
: [DEFAULT_ACCEPT_HEADER]
47+
const numPreviews = operation.previews?.length || 0
48+
const hasStatusCodes = operation.statusCodes?.length > 0
49+
const hasCodeSamples = operation.codeExamples?.length > 0
50+
const hasParameters = operation.parameters?.length > 0 || operation.bodyParameters?.length > 0
4251

4352
const anchorRef = useRef<null | HTMLDivElement>(null)
4453

0 commit comments

Comments
 (0)