BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/neon-ui/use-gateway-models

useGatewayModels

neon-ui/use-gateway-models
FreeHook

Fetches a gateway model catalog and keeps the selection valid against it: explicit pick, then preferred default, then first available.

Install it

npx shadcn@latest add https://ui.neon.com/r/use-gateway-models.json

Source

src/hooks/use-gateway-models.tsui.neon.com/r/use-gateway-models.json
1"use client";
2
3import { useEffect, useMemo, useState } from "react";
4
5/** Structurally compatible with ModelSelect's AiModel. */
6export interface GatewayModel {
7 /** Gateway model id in short form, e.g. "gpt-5-2". */
8 id: string;
9 /** Human-readable name, e.g. "GPT-5.2". */
10 name: string;
11 /** Provider name used for grouping, e.g. "OpenAI". */
12 provider: string;
13 /** Whether the model supports extended reasoning. */
14 reasoning?: boolean;
15}
16
17export type GatewayModelsStatus = "loading" | "ready" | "error";
18
19export interface UseGatewayModelsOptions {
20 /**
21 * URL of the catalog endpoint. Point it at your server-side proxy in
22 * front of the gateway's `GET /v1/models` — the bearer token must not
23 * ship to the browser. Accepts either the raw OpenAI-compatible shape
24 * (`{ data: [...] }`, filtered to enabled models) or a pre-shaped
25 * `{ models: GatewayModel[] }` payload.
26 */
27 endpoint?: string;
28 /** Preferred model id; wins whenever the catalog includes it. */
29 defaultModel?: string;
30}
31
32/** Raw entry from the gateway's OpenAI-compatible `GET /v1/models`. */
33interface RawGatewayModel {
34 id: string;
35 name?: string;
36 owned_by?: string;
37 enabled?: boolean;
38}
39
40/** Display names for `owned_by` slugs the gateway reports. */
41const PROVIDER_NAMES: Record<string, string> = {
42 alibaba: "Alibaba",
43 anthropic: "Anthropic",
44 databricks: "Databricks",
45 google: "Google",
46 meta: "Meta",
47 "meta-llama": "Meta",
48 mistral: "Mistral",
49 moonshot: "Moonshot AI",
50 openai: "OpenAI",
51 qwen: "Qwen",
52 zhipu: "Zhipu AI",
53};
54
55const shapeModels = (payload: unknown): GatewayModel[] => {
56 if (typeof payload !== "object" || payload === null) {
57 return [];
58 }
59
60 // Pre-shaped proxy response: { models: GatewayModel[] }.
61 if ("models" in payload && Array.isArray(payload.models)) {
62 return payload.models as GatewayModel[];
63 }
64
65 // OpenAI-compatible response: { data: [...] }, keep enabled models only.
66 if ("data" in payload && Array.isArray(payload.data)) {
67 return (payload.data as RawGatewayModel[])
68 .filter((model) => model.enabled !== false)
69 .map((model) => ({
70 id: model.id,
71 name: model.name || model.id,
72 provider:
73 PROVIDER_NAMES[model.owned_by ?? ""] ?? model.owned_by ?? "Other",
74 }));
75 }
76
77 return [];
78};
79
80/**
81 * The live model catalog of a Neon AI Gateway branch, with a selection
82 * that is always valid against it: an explicit pick wins while listed,
83// … truncated

Files it writes

  • src/hooks/use-gateway-models.ts

Facts

Registry
neon-ui
Type
registry:hook
Access
Free
Files written
1
Licence
MIT
In the index
at or before 2026-08-09
Last confirmed
today

Go to the source

ui.neon.com neondatabase/ui on GitHub Raw registry item This item as JSON

More from neon-ui

All 77 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
useConsumptionHistoryuse-consumption-historyneon-uiHooksFreeno deps
useRegionPinguse-region-pingneon-uiHooksFreeno deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex