Basic usage
Basic usage
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen3-4B');
// provide the model with input
const input = [
{
"role": "system",
"content": "You are a friendly chatbot"
},
{
"role": "assistant",
"content": "Hello, I'm a friendly bot"
},
{
"role": "user",
"content": "Hello bot, what is the capital of England?"
}
];
// send to the model
const { error, output } = await model.run(input);
// observe the output
console.log({ error, output });
Add params
Add params
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen3-4B');
// provide the model with input
const input = [
{
"role": "system",
"content": "You are a friendly chatbot"
},
{
"role": "assistant",
"content": "Hello, I'm a friendly bot"
},
{
"role": "user",
"content": "Hello bot, what is the capital of England?"
}
];
// provide the model with params
const params = {
"temperature": 0
};
// send to the model
const { error, output } = await model.run(input, params);
// observe the output
console.log({ error, output });
Stream text
Stream text
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen3-4B');
// provide the model with input
const input = [
{
"role": "system",
"content": "You are a friendly chatbot"
},
{
"role": "assistant",
"content": "Hello, I'm a friendly bot"
},
{
"role": "user",
"content": "Hello bot, what is the capital of England?"
}
];
// set streaming to "true"
const stream = true;
// send to the model
const readStream = await model.run(input, stream);
let text = '';
for await (const chunk of readStream) {
text += chunk;
console.log(chunk);
}
// observe the output
console.log({ text });
Add params + Stream text
Add params + Stream text
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen3-4B');
// provide the model with input
const input = [
{
"role": "system",
"content": "You are a friendly chatbot"
},
{
"role": "assistant",
"content": "Hello, I'm a friendly bot"
},
{
"role": "user",
"content": "Hello bot, what is the capital of England?"
}
];
// provide the model with params
const params = {
"temperature": 0
};
// set streaming to "true"
const stream = true;
// send to the model
const readStream = await model.run(input, params, stream);
let text = '';
for await (const chunk of readStream) {
text += chunk;
console.log(chunk);
}
// observe the output
console.log({ text });