Gateway
Quickstart
Make your first Hull Gateway request with the Vercel AI SDK, the OpenAI SDK or cURL.
This guide gets you from zero to a streamed response from Hull Gateway in a few minutes.
Before you start
- A Hull account. Sign up at app.withhull.com.
- Your Hull API key. See Get your API key.
- Paid models count against your plan's AI allowance. See Usage and billing.
Vercel AI SDK
Create a project
mkdir my-ai-app
cd my-ai-app
npm init -y
npm install ai @ai-sdk/openai dotenvWrite and run a script
Create index.mjs:
import { streamText } from "ai"
import { createOpenAI } from "@ai-sdk/openai"
import "dotenv/config"
const hull = createOpenAI({
baseURL: "https://api.withhull.com/api/gateway",
apiKey: process.env.HULL_API_KEY,
})
const result = streamText({
model: hull.chat("anthropic/claude-sonnet-5"),
prompt: "Invent a new holiday and describe its traditions.",
})
for await (const textPart of result.textStream) {
process.stdout.write(textPart)
}
console.log()
console.log("Token usage:", await result.usage)node index.mjsThe response streams to your terminal.
OpenAI SDK
Hull Gateway accepts OpenAI Chat Completions requests, so the OpenAI SDK works by changing the base URL.
import OpenAI from "openai"
const client = new OpenAI({
apiKey: process.env.HULL_API_KEY,
baseURL: "https://api.withhull.com/api/gateway",
})
const response = await client.chat.completions.create({
model: "anthropic/claude-sonnet-5",
messages: [{ role: "user", content: "Why is the sky blue?" }],
})
console.log(response.choices[0].message.content)cURL
curl -X POST "https://api.withhull.com/api/gateway/chat/completions" \
-H "Authorization: Bearer $HULL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"messages": [{"role": "user", "content": "Why is the sky blue?"}]
}'Next steps
- Models and providers: find model IDs and use Auto.
- Streaming: handle server-sent events.
- API reference: every endpoint and field.