SDKs & languages

Any OpenAI-compatible client works: set the base URL and the key. The samples read the key from the GRIDPORT_API_KEY environment variable.

Python

bash
pip install openai
python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://gridport.ai/v1",
    api_key=os.environ["GRIDPORT_API_KEY"],
)
resp = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Flash",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)

Node.js / TypeScript

bash
npm i openai
node
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://gridport.ai/v1", apiKey: process.env.GRIDPORT_API_KEY });
const stream = await client.chat.completions.create({
  model: "deepseek-ai/DeepSeek-V4-Flash",
  messages: [{ role: "user", content: "Hello" }],
  stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
console.log();

cURL

curl
curl https://gridport.ai/v1/chat/completions \
  -H "Authorization: Bearer $GRIDPORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-ai/DeepSeek-V4-Flash","messages":[{"role":"user","content":"Hello"}]}'

Frameworks

python
import os

# LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="deepseek-ai/DeepSeek-V4-Flash", base_url="https://gridport.ai/v1", api_key=os.environ["GRIDPORT_API_KEY"])

# LlamaIndex
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(model="deepseek-ai/DeepSeek-V4-Flash", api_base="https://gridport.ai/v1", api_key=os.environ["GRIDPORT_API_KEY"], is_chat_model=True)
node
// Vercel AI SDK
import { createOpenAI } from "@ai-sdk/openai";
const tf = createOpenAI({ baseURL: "https://gridport.ai/v1", apiKey: process.env.GRIDPORT_API_KEY });
const model = tf("deepseek-ai/DeepSeek-V4-Flash");

What we test

Before a release we run the official Python and Node SDKs against the gateway: model list, chat, streaming with usage, tool calling, JSON mode, embeddings, the request-id header, and the error mapping for 401 and 404.