npm install v0studio
yarn add v0studio
pnpm add v0studio
<script src="https://unpkg.com/v0studio@latest/dist/v0studio.min.js"></script>
import { V0Studio } from 'v0studio';
// Initialize the client
const v0 = new V0Studio({
serverUrl: 'http://localhost:1234',
apiKey: 'your-api-key' // Optional for local usage
});
// Simple text completion
async function basicCompletion() {
try {
const response = await v0.completions.create({
model: 'llama-3-8b-instruct',
prompt: 'Explain quantum computing in simple terms:',
maxTokens: 200,
temperature: 0.7
});
console.log(response.choices[0].text);
} catch (error) {
console.error('Error:', error.message);
}
}
basicCompletion();
Interactive video tutorials with code examples, transcripts, and note-taking features
5:30
8:15
First, let's import the v0studio SDK and set up our client.
We import the V0Studio class and create a new client instance pointing to your local v0studio server.
Click "Run Code" to see output...
import { V0Studio } from 'v0studio';
// Initialize the client
const v0 = new V0Studio({
serverUrl: 'http://localhost:1234',
apiKey: 'your-api-key' // Optional for local usage
});
// Simple text completion
async function basicCompletion() {
try {
const response = await v0.completions.create({
model: 'llama-3-8b-instruct',
prompt: 'Explain quantum computing in simple terms:',
maxTokens: 200,
temperature: 0.7
});
console.log(response.choices[0].text);
} catch (error) {
console.error('Error:', error.message);
}
}
basicCompletion();
Main client class
Error handling
Generate text completions
{
model: string,
prompt: string,
maxTokens?: number,
temperature?: number,
stream?: boolean
}
Create chat completions
{
model: string,
messages: Message[],
maxTokens?: number,
temperature?: number,
stream?: boolean
}
List available models
Returns: Promise<ModelsList>
import { V0Studio } from 'v0studio';
const v0 = new V0Studio({
serverUrl: 'http://localhost:1234', // v0studio server URL
apiKey: 'your-api-key', // Optional API key
timeout: 30000, // Request timeout (ms)
retries: 3, // Number of retry attempts
headers: { // Additional headers
'User-Agent': 'my-app/1.0.0'
},
proxy: { // Proxy settings
host: 'proxy.example.com',
port: 8080,
auth: {
username: 'user',
password: 'pass'
}
}
});
// Environment variables
// V0STUDIO_SERVER_URL
// V0STUDIO_API_KEY
The v0studio-js SDK includes full TypeScript support with comprehensive type definitions.
import {
V0Studio,
CompletionResponse,
ChatMessage,
Model,
FineTuningJob
} from 'v0studio';
const v0 = new V0Studio();
// Typed responses
const completion: CompletionResponse = await v0.completions.create({
model: 'llama-3-8b-instruct',
prompt: 'Hello world',
maxTokens: 100
});
// Typed messages
const messages: ChatMessage[] = [
{ role: 'system', content: 'You are helpful.' },
{ role: 'user', content: 'What is TypeScript?' }
];
// Custom interfaces
interface CustomConfig {
temperature: number;
customParameter: string;
}
const config: CustomConfig = {
temperature: 0.7,
customParameter: 'value'
};
If you're having trouble connecting to v0studio:
curl http://localhost:1234/v1/models
For large models or long conversations:
Tips for better performance: