My NodeJS code is like so:
const payload = {
model: 'gpt-3.5-turbo',
messages: [{ "role": "user", "content": "output 1000 tokens" }],
max_tokens: 1000,
stream: true,
};
const stream = await openaiClient.chat.completions.create(payload);
let chunksGot = 0;
for await (const chunk of stream) {
chunksGot++;
if (chunksGot > 100) {
break;
}
let choice = chunk.choices[0];
if (choice?.finish_reason) {
break;
}
// do something with choice.delta.content
}
// Abort connection
stream.controller.abort();
My question is: as I have aborted the connected after receiving ~100 tokens, do I still get billed for the remaining ~900 tokens in the incoming output (that I never received)?