Basic usage
Basic usage
Send a conversation to a model to generate text from text and audio
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen2-Audio-7B-Instruct');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
];
// send to the model
const { error, output } = await model.run(input);
// observe the output
console.log({ error, output });
from bytez import Bytez
# insert your key
sdk = Bytez("BYTEZ_KEY")
# choose your model
model = sdk.model("Qwen/Qwen2-Audio-7B-Instruct")
# provide the model with input
input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
]
# send to the model
result = model.run(input)
# observe the output
print({"error": result.error, "output": result.output})
curl -X POST 'https://api.bytez.com/models/v2/Qwen/Qwen2-Audio-7B-Instruct' \
-H 'Authorization: BYTEZ_KEY' \
-H 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
]
}'
Add params
Add params
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen2-Audio-7B-Instruct');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
];
// 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 });
from bytez import Bytez
# insert your key
sdk = Bytez("BYTEZ_KEY")
# choose your model
model = sdk.model("Qwen/Qwen2-Audio-7B-Instruct")
# provide the model with input
input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
]
# provide the model with params
params = {
"temperature": 0
}
# send to the model
result = model.run(input, params)
# observe the output
print({"error": result.error, "output": result.output})
curl -X POST 'https://api.bytez.com/models/v2/Qwen/Qwen2-Audio-7B-Instruct' \
-H 'Authorization: BYTEZ_KEY' \
-H 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
],
"params": {
"temperature": 0
}
}'
Stream text
Stream text
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen2-Audio-7B-Instruct');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
];
// set streaming to "true"
const stream = true;
// send to the model
const readStream = await model.run(input, stream);
let text = '';
for await (const tokens of readStream) {
text += tokens;
console.log(tokens);
}
// observe the output
console.log({ text });
from bytez import Bytez
# insert your key
sdk = Bytez("BYTEZ_KEY")
# choose your model
model = sdk.model("Qwen/Qwen2-Audio-7B-Instruct")
# provide the model with input
input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
]
# set streaming to "true"
stream = True
# send to the model
readStream = model.run(input, stream=stream)
text = ""
for tokens in readStream:
text += tokens
print(tokens)
# observe the output
print({"text": text})
curl -X POST 'https://api.bytez.com/models/v2/Qwen/Qwen2-Audio-7B-Instruct' \
-H 'Authorization: BYTEZ_KEY' \
-H 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
],
"stream": true
}'
Add params + Stream text
Add params + Stream text
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('Qwen/Qwen2-Audio-7B-Instruct');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
];
// 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 tokens of readStream) {
text += tokens;
console.log(tokens);
}
// observe the output
console.log({ text });
from bytez import Bytez
# insert your key
sdk = Bytez("BYTEZ_KEY")
# choose your model
model = sdk.model("Qwen/Qwen2-Audio-7B-Instruct")
# provide the model with input
input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
]
# provide the model with params
params = {
"temperature": 0
}
# set streaming to "true"
stream = True
# send to the model
readStream = model.run(input, params, stream)
text = ""
for tokens in readStream:
text += tokens
print(tokens)
# observe the output
print({"text": text})
curl -X POST 'https://api.bytez.com/models/v2/Qwen/Qwen2-Audio-7B-Instruct' \
-H 'Authorization: BYTEZ_KEY' \
-H 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this audio"
},
{
"type": "audio",
"url": "https://dn720307.ca.archive.org/0/items/various-bird-sounds/Various%20Bird%20Sounds.mp3"
}
]
}
],
"params": {
"temperature": 0
},
"stream": true
}'