Version 3.0.0 · Serverless · Free Forever · No Backend
Created by Clobax-Creator (Avyaan Mishra) · GPL v3
Include the SDK in your HTML:
Create an instance:
const dc = new DviCoder({
apiKey: 'your-api-key',
provider: 'openrouter', // sarvam, openai, groq, openrouter, or custom
// baseUrl: 'https://custom-api.com/v1', // optional, for custom
// model: 'gpt-4o', // optional, auto-detected if omitted
// temperature: 0.7, // optional (default 0.7)
// maxTokens: 4096, // optional (default 4096)
});
| Provider | Key Format | Base URL |
|---|---|---|
| sarvam | sk_... | https://api.sarvam.ai/v1 |
| openai | sk-... | https://api.openai.com/v1 |
| groq | gsk_... | https://api.groq.com/openai/v1 |
| openrouter | sk-or-v1-... | https://openrouter.ai/api/v1 |
| custom | any | your-url |
Send a chat message to the AI. Returns the response text.
const reply = await dc.chat('Write a Python function to sort a list');
console.log(reply);
// With custom history (doesn't use internal history)
const reply2 = await dc.chat('Explain it simpler', [
{ role: 'user', content: 'Write a Python function to sort a list' },
{ role: 'assistant', content: 'def sort_list(l): return sorted(l)' },
]);
message (string) — User's message
history (array, optional) — Override chat history
Returns Promise
Stream a chat response token-by-token. Calls onToken for each chunk.
await dc.chatStream('Write a story', (chunk, fullText) => {
document.getElementById('output').textContent = fullText;
});
message (string) — User's message
onToken (function) — Callback(chunk, fullText)
history (array, optional) — Override chat history
Returns Promise
List available models from the AI provider.
const models = await dc.models();
// ['sarvam-m', 'sarvam-2b', 'gpt-4o', ...]
dc.setModel('gpt-4o');
Returns Promise
List all files in a GitHub repo (recursive).
const files = await dc.githubList('pandeykhushbu29-eng', 'Dvidvar', 'ghp_xxx');
// [{ path: 'README.md', size: 5000 }, { path: 'ISA.md', size: 12000 }, ...]
Returns Promise
Read a file from a GitHub repo.
const file = await dc.githubRead('user', 'repo', 'README.md', 'ghp_xxx');
console.log(file.content); // file text content
Returns Promise<{path, content, size}>
Create or update a file in a GitHub repo.
await dc.githubCommit('user', 'repo', 'test.py', 'print("hello")', 'ghp_xxx', 'Add test.py');
Returns Promise<{success, commitUrl}>
Upload a file to a Hugging Face repo (Space, model, or dataset).
await dc.hfUpload('Clobax-Creator/Dvidata', 'data.json', '{"key":"value"}', 'hf_xxx');
Returns Promise<{success, url}>
List files in a Hugging Face repo.
const files = await dc.hfList('Clobax-Creator/Dvidata', 'hf_xxx');
// [{ path: 'README.md', size: 2000 }, ...]
Returns Promise
Clear the internal chat history.
Change the AI model.
dc.setModel('gpt-4o');
Change the AI provider and/or base URL.
dc.setProvider('groq');
dc.setProvider('custom', 'https://my-api.com/v1');
Everything runs in the browser. No backend, no server, no cost.
User's browser
├── Downloads dvi-coder.js (one time, from HF static hosting)
├── Calls AI API directly (Sarvam/OpenAI/Groq/OpenRouter)
├── Calls GitHub API directly (CORS supported)
└── Calls HuggingFace API directly (CORS supported)
You host the JS file on HF Static Spaces (free). Developers include it. Their users' browsers do all the work. You pay nothing. They pay nothing. The only cost is each user's own API key.
Dvi-Coder.js v3.0.0 · Clobax-Creator (Avyaan Mishra) · GPL v3