Skip to content
Heimdallm
Marketplace/Documentation
Documentation · Guides

SDKs & frameworks

Every client on this page is configured with two values: a base URL and a Heimdallm API key (sk-hd-v1-…, see Authentication). Model ids are author/slug catalogue ids, copied verbatim from the catalogue including any variant suffix.

Two base URLs cover everything here. The OpenAI wire and the OpenRouter conventions are served under

https://api-staging.heimdallm.com/api/v1

where a client appends /chat/completions, /embeddings or /models. The Anthropic Messages dialect is served under

https://api-staging.heimdallm.com/api

because the Anthropic SDKs append /v1/messages themselves, which lands on the Messages route.

The Heimdallm SDKs (@heimdallm/sdk, heimdallm-sdk on PyPI) are the first-party clients: they cover the whole API, including video and mesh jobs, rerank, files, batches, the catalogue and generation costs, which the clients on this page have no surface for.

What the compatibility matrix runs

A compatibility matrix installs the published SDKs listed below at the versions npm resolves, points each at a running marketplace with a real key, and records pass or fail per capability: chat, streaming, tools, structured outputs, embeddings, usage and cost, and the error envelope. A client the matrix does not run follows its own documented OpenAI-compatible settings; nothing here claims a pass for it.

ClientPackageMatrix row
OpenAI Node SDKopenaiopenai-node
Anthropic Node SDK@anthropic-ai/sdkanthropic-node
Vercel AI SDK via the OpenRouter provider@openrouter/ai-sdk-providervercel-ai-openrouter
OpenAI Python SDKpypi:openaiopenai-python
LiteLLMpypi:litellmlitellm-openrouter
LangChain JavaScript@langchain/openailangchain-node
LangChain Pythonlangchain-openainone
LlamaIndex Pythonpypi:llama-index-llms-openai-likellamaindex-python

OpenAI SDKs

Matrix row openai-node. Change baseURL and the key; everything else in an existing integration stays.

import OpenAI from 'openai';

const client = new OpenAI({
baseURL: 'https://api-staging.heimdallm.com/api/v1',
apiKey: process.env.HEIMDALL_API_KEY,
});

const completion = await client.chat.completions.create({
model: 'deepseek/deepseek-v4-flash-0731-abliterated',
messages: [{ role: 'user', content: 'Name the capital of Iceland.' }],
});

Matrix row openai-python. The report identifies the PyPI distribution as pypi:openai.

import os
from openai import OpenAI

client = OpenAI(
  base_url="https://api-staging.heimdallm.com/api/v1",
  api_key=os.environ["HEIMDALL_API_KEY"],
)

completion = client.chat.completions.create(
  model="deepseek/deepseek-v4-flash-0731-abliterated",
  messages=[{"role": "user", "content": "Name the capital of Iceland."}],
)

The same client reaches embeddings, speech, transcription and rerank at the paths in the API reference. The reply carries two members the OpenAI types do not declare, provider and usage.cost; both are on the parsed object as extra members and in the raw body. Streaming ends with a final chunk whose choices array is empty and whose usage is complete — see the streaming guide.

Reference image requests with the OpenAI clients

The matrix's image_reference cell uses each OpenAI SDK's generic request method to call the reference Image API. This is an explicit API extension: the SDK's images.generate method names a different route and is unsupported.

const image = await client.post('/images', {
  body: {
    model: 'author/image-model',
    prompt: 'A plain red circle centered on a white background.',
    n: 1,
    size: '512x512',
    output_format: 'png',
  },
});
image = client.post('/images', cast_to=dict, body={
    'model': 'author/image-model',
    'prompt': 'A plain red circle centered on a white background.',
    'n': 1,
    'size': '512x512',
    'output_format': 'png',
})

Use an image-output model from the catalogue and a size within its declared image envelope. The matrix resolves the model from declared image prices, decodes the returned PNG and checks its 512×512 dimensions and reported cost. A missing cost is not a zero. Framework and gateway rows that expose no corresponding reference-image method report a skip for this cell.

Anthropic SDKs

Matrix row anthropic-node. The SDK appends /v1/messages to the base URL it is given, so the base URL is the API origin plus /api. It sends the key as x-api-key, which the gateway accepts like an Authorization: Bearer header.

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
baseURL: 'https://api-staging.heimdallm.com/api',
apiKey: process.env.HEIMDALL_API_KEY,
});

const message = await client.messages.create({
model: 'deepseek/deepseek-v4-flash-0731-abliterated',
max_tokens: 256,
messages: [{ role: 'user', content: 'Name the capital of Iceland.' }],
});
import os
import anthropic

client = anthropic.Anthropic(
  base_url="https://api-staging.heimdallm.com/api",
  api_key=os.environ["HEIMDALL_API_KEY"],
)

message = client.messages.create(
  model="deepseek/deepseek-v4-flash-0731-abliterated",
  max_tokens=256,
  messages=[{"role": "user", "content": "Name the capital of Iceland."}],
)

The model is a marketplace id, not an Anthropic model name. The Messages usage object has no cost member, so read the charge from GET /generation or a chat completions reply. See Messages for the supported content blocks.

Vercel AI SDK

Matrix row vercel-ai-openrouter. An application that already uses @openrouter/ai-sdk-provider changes baseURL and the key. Attribution headers it sets (HTTP-Referer, X-OpenRouter-Title or X-Title) are recorded with the generation, as the chat reference describes.

import { createOpenRouter } from '@openrouter/ai-sdk-provider';
import { embed, generateText } from 'ai';

const heimdall = createOpenRouter({
baseURL: 'https://api-staging.heimdallm.com/api/v1',
apiKey: process.env.HEIMDALL_API_KEY,
extraBody: { usage: { include: true } },
});

const { text, providerMetadata } = await generateText({
model: heimdall.chat('deepseek/deepseek-v4-flash-0731-abliterated'),
prompt: 'Name the capital of Iceland.',
});

const { embedding } = await embed({
model: heimdall.textEmbeddingModel('baai/bge-m3'),
value: 'Reykjavik is the capital of Iceland.',
});

The charge is at providerMetadata.openrouter.usage.cost. The provider package exposes chat and embeddings; use the OpenAI SDK for speech, transcription and rerank.

LiteLLM

Matrix row litellm-openrouter. The report identifies the PyPI distribution as pypi:litellm.

LiteLLM's openrouter provider sends the OpenRouter wire to whatever api_base it is given. The model string is openrouter/ followed by the catalogue id.

import os
import litellm

response = litellm.completion(
  model="openrouter/deepseek/deepseek-v4-flash-0731-abliterated",
  api_base="https://api-staging.heimdallm.com/api/v1",
  api_key=os.environ["HEIMDALL_API_KEY"],
  messages=[{"role": "user", "content": "Name the capital of Iceland."}],
)

LiteLLM also reads the base URL from OPENROUTER_API_BASE and the key from OPENROUTER_API_KEY, which lets one process switch between a deployment and another without a code change. To run LiteLLM as a proxy in front of Heimdallm, see Gateways.

LangChain

Matrix row langchain-node. The JavaScript @langchain/openai chat wrapper accepts a base URL through configuration; modelKwargs requests the marketplace's cost accounting. Read response_metadata.usage for token counts and cost on both buffered messages and the final streamed usage chunk. usage_metadata contains token counts without cost.

import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai';

const settings = {
apiKey: process.env.HEIMDALL_API_KEY,
configuration: { baseURL: 'https://api-staging.heimdallm.com/api/v1' },
};
const chat = new ChatOpenAI({
...settings,
model: 'deepseek/deepseek-v4-flash-0731-abliterated',
modelKwargs: { usage: { include: true } },
maxRetries: 0,
});
const reply = await chat.invoke('Hello');
console.log(reply.content, reply.response_metadata.usage);

const embeddings = new OpenAIEmbeddings({
...settings,
model: 'baai/bge-m3',
});

The matrix exercises bindTools, withStructuredOutput using jsonSchema, and embedQuery. The JavaScript wrappers have no model-retrieval, speech, transcription, rerank or System One methods; those cells are explicit skips. The Python configuration below is documented independently of the JavaScript matrix row.

langchain-openai takes the OpenAI-compatible settings directly.

import os
from langchain_openai import ChatOpenAI, OpenAIEmbeddings

chat = ChatOpenAI(
  model="deepseek/deepseek-v4-flash-0731-abliterated",
  base_url="https://api-staging.heimdallm.com/api/v1",
  api_key=os.environ["HEIMDALL_API_KEY"],
  stream_usage=True,
)

embeddings = OpenAIEmbeddings(
  model="baai/bge-m3",
  base_url="https://api-staging.heimdallm.com/api/v1",
  api_key=os.environ["HEIMDALL_API_KEY"],
  check_embedding_ctx_length=False,
)

check_embedding_ctx_length=False makes the client send text instead of token ids, which is what an embeddings endpoint that is not OpenAI's expects. ChatOpenAI does not extract response members outside the OpenAI specification, so the reasoning text a reasoning model streams in delta.reasoning and the provider member are not on its messages; call the OpenAI SDK directly where they matter.

LlamaIndex

Matrix row llamaindex-python. The Python packages are pypi:llama-index-llms-openai-like and llama-index-embeddings-openai-like.

LlamaIndex reaches an OpenAI-compatible endpoint through its OpenAILike classes. Set is_chat_model so chat messages use /chat/completions, and is_function_calling_model only for a model whose catalogue entry lists tools in supported_parameters.

import os
from llama_index.llms.openai_like import OpenAILike
from llama_index.embeddings.openai_like import OpenAILikeEmbedding

llm = OpenAILike(
  model="deepseek/deepseek-v4-flash-0731-abliterated",
  api_base="https://api-staging.heimdallm.com/api/v1",
  api_key=os.environ["HEIMDALL_API_KEY"],
  is_chat_model=True,
  context_window=32768,
  max_retries=0,
  additional_kwargs={"extra_body": {"usage": {"include": True}}},
)

embedding = OpenAILikeEmbedding(
  model_name="baai/bge-m3",
  api_base="https://api-staging.heimdallm.com/api/v1",
  api_key=os.environ["HEIMDALL_API_KEY"],
)

context_window is the model's own context_length from the catalogue; LlamaIndex uses it to size prompts, and a value larger than the model's is a request the router trims or refuses.

Chat responses expose the marketplace's full accounting object through reply.raw.usage. For streamed chat, pass stream_options={"include_usage": True} to stream_chat and inspect the final chunk's raw.usage. Normalized token counts in additional_kwargs do not carry cost. The matrix exercises buffered and streamed chat, demanded tools, JSON Schema output and embeddings; unsupported wrapper methods are explicit skips.

When a client fails

A failure is attributable by its status and body. Every error is the one envelope in Errors & rate limits, so a client that surfaces the response body shows error.metadata.error_type. A 401 is the key, a 402 the balance, a 400 the request, and a 404 no_route with metadata.rejections a constraint no live endpoint satisfied; see Troubleshooting & FAQ. Chat completions accept n: 1 only.

DiscoverFind your next modelModel libraryAll models, versions, prices and capabilitiesBenchmarksMeasured quality, cost and time by serving configurationModel requestsAsk for a model, and vote on what is listed nextShowcaseImages, video and 3D made on the marketplaceProvidersCompare independent inference providersActivityMarketplace traffic and usageNetwork statusAvailability, latency and endpoint healthChatConversations, model settings and filesImage, video & 3DGenerate images, video and 3D assetsScene studioStage a shot in 3D, direct it and render it as a videoCoding playgroundBuild software with an AI agent on a machine of your ownOverview & routingIdentity, workspaces and routing preferencesBalance & depositsBalance, deposits, ledger and reserved fundsAPI keysKeys scoped to workspaces, limits and expirationOrganizationsTeams, members and shared workspacesRequest historyRequests, receipts, sandbox sessions and account historyReferralsInvitations and referral earningsPrivacyData settings, exports and deletionDocumentationQuickstart, SDKs, pricing and guidesAPI referenceInteractive endpoint referenceList your modelsProvider guide: requirements, the fee, payouts and what is measuredProvider payoutsMonthly statements, the marketplace fee and payout walletsProvider dashboardApply as a provider, add sources and track earnings