API · Guides
Use VANTRA with your framework
The VANTRA API is OpenAI-compatible, so the libraries you already use work with a different base URL and key. Every example below was run against the live API.
01OpenAI Responses API
Newer OpenAI SDKs and agent tools use the Responses API, at POST /api/v1/responses. VANTRA supports text and picture input, instructions, function tools and their outputs, JSON output (text.format), reasoning effort on Core Apex, and streaming. Chat completions work too, as in the API docs.
// npm install openai
import OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://vantra.cloud/api/v1', apiKey: process.env.VANTRA_API_KEY })
const response = await client.responses.create({
model: 'core-apex',
instructions: 'Answer briefly.',
input: 'Why is my React effect running twice in development?',
})
console.log(response.output_text)Because VANTRA keeps nothing, responses aren’t stored: store is always false, and previous_response_id returns an error. Send the whole conversation in input, including function_call and function_call_output items. Built-in tools (web search, file search, code interpreter) aren’t available.
02Vercel AI SDK
Use the OpenAI-compatible provider. Text, streaming, tool calls and embeddings all work.
// npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
import { embed, generateText, streamText } from 'ai'
const vantra = createOpenAICompatible({
name: 'vantra',
baseURL: 'https://vantra.cloud/api/v1',
apiKey: process.env.VANTRA_API_KEY,
})
const { text } = await generateText({ model: vantra('core-apex'), prompt: 'Explain closures in one paragraph.' })
const result = streamText({ model: vantra('core-swift'), prompt: 'Write a haiku about tests.' })
for await (const part of result.textStream) process.stdout.write(part)
const { embedding } = await embed({ model: vantra.textEmbeddingModel('core-embed'), value: 'function add(a, b) {}' })03LangChain
Point the OpenAI integration at VANTRA. Invoke, streaming, tools (bindTools) and embeddings all work.
// npm install @langchain/openai @langchain/core
import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai'
const llm = new ChatOpenAI({
model: 'core-apex',
apiKey: process.env.VANTRA_API_KEY,
configuration: { baseURL: 'https://vantra.cloud/api/v1' },
})
const reply = await llm.invoke('Review this function for bugs: ...')
const embeddings = new OpenAIEmbeddings({
model: 'core-embed',
apiKey: process.env.VANTRA_API_KEY,
configuration: { baseURL: 'https://vantra.cloud/api/v1' },
})
const vector = await embeddings.embedQuery('how do I reset a password?')# pip install langchain-openai
import os
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
llm = ChatOpenAI(model="core-apex", api_key=os.environ["VANTRA_API_KEY"], base_url="https://vantra.cloud/api/v1")
reply = llm.invoke("Review this function for bugs: ...")
embeddings = OpenAIEmbeddings(
model="core-embed", api_key=os.environ["VANTRA_API_KEY"], base_url="https://vantra.cloud/api/v1",
check_embedding_ctx_length=False, # send text as it is, not OpenAI token IDs
)
vector = embeddings.embed_query("how do I reset a password?")04LlamaIndex
Use the OpenAI-like integrations, so LlamaIndex doesn’t check model names against OpenAI’s list.
# pip install llama-index-llms-openai-like llama-index-embeddings-openai-like
import os
from llama_index.llms.openai_like import OpenAILike
from llama_index.embeddings.openai_like import OpenAILikeEmbedding
llm = OpenAILike(
model="core-apex", api_base="https://vantra.cloud/api/v1", api_key=os.environ["VANTRA_API_KEY"],
is_chat_model=True, is_function_calling_model=True, context_window=1_000_000,
)
print(llm.complete("Explain dependency injection in two sentences."))
embed_model = OpenAILikeEmbedding(model_name="core-embed", api_base="https://vantra.cloud/api/v1", api_key=os.environ["VANTRA_API_KEY"])
vector = embed_model.get_text_embedding("how do I reset a password?")05What to know
- Models: core-apex for hard problems and agents, core-swift for fast answers and pictures, core-embed for embeddings.
- Each request is charged to your prepaid credit and shows up under Recent requests on Your API, with its request ID.
- Keep your key in an environment variable on a server. Never put it in a web page or app people download.