Use the Vercel AI SDK with an uncensored LLM API
The AI SDK talks to OpenAI-style servers through the @ai-sdk/openai-compatible package. You build a provider once, then hand its models to generateText, streamText and the rest.
Set it up
- Sign in at wildwestapi.com/signup/ with the six-digit code sent to your email, open the dashboard and create an API key. It starts with sk-ww- and is shown in full once, so copy it somewhere safe.
- Install the packages with npm install ai @ai-sdk/openai-compatible.
- Add WILDWEST_API_KEY to .env.local, or your host's environment settings.
- Call createOpenAICompatible with a name, baseURL https://wildwestapi.com/v1 and your apiKey.
- Pass wildwest('outlaw-1') as the model to generateText or streamText, in server code only.
Provider and a text call
The docs list name, baseURL, apiKey, headers and includeUsage as the options. The key is sent as a bearer token in the Authorization header.
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText, streamText } from 'ai';
const wildwest = createOpenAICompatible({
name: 'wildwest',
baseURL: 'https://wildwestapi.com/v1',
apiKey: process.env.WILDWEST_API_KEY,
includeUsage: true,
});
const { text } = await generateText({
model: wildwest('outlaw-1'),
prompt: 'Write the opening of a noir story.',
});
Streaming in a route handler
result.textStream is both a ReadableStream and an async iterable, so you can loop over it or return it from a Next.js route.
const result = streamText({
model: wildwest.chatModel('outlaw-1'),
prompt: 'Tell me a short ghost story.',
});
for await (const part of result.textStream) {
process.stdout.write(part);
}chatModel() is the explicit chat-completions model. wildwest('id') and languageModel('id') do the same thing.
Tools
The provider page lists tool calling as supported, including streamed tool calls. Define tools in the usual AI SDK way, with an input schema and an execute function, on a model that supports tools. Check the models page for which do.
One limit to know
The call must run on the server. If you use useChat in a React component, point it at your own route handler that runs streamText. Never give the client the key, and do not call wildwestapi.com from the browser: it will fail on cross-origin rules.
FAQ
Why not the @ai-sdk/openai package?
The compatible package is built for third-party servers and the Chat Completions path, which is the one Wild West documents. Use it so you are not depending on OpenAI-only behaviour.
What is includeUsage for?
It asks for token usage in streaming responses. It is off by default. Remove it if a stream ever errors out.