Quantcast
Channel: how can I count tokens before making api call? - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by EL MAHDI Bouzkoura for how can I count tokens before making api call?

Question is old but it may help someone. There is a node.js library called tiktoken wish is a fork form the original tiktoken library.All the examples on the official tiktoken repo are valid with a...

View Article


Image may be NSFW.
Clik here to view.

Answer by Schroeder for how can I count tokens before making api call?

Exact MethodA precise way is to use tiktoken, which is a python library. Taken from the openAI cookbook: import tiktoken encoding = tiktoken.encoding_for_model("gpt-3.5-turbo") num_tokens =...

View Article


how can I count tokens before making api call?

import { Configuration, OpenAIApi } from "openai"import { readFile } from './readFile.js'// Config OpenAI APIconst configuration = new Configuration({ organization: "xyx......", apiKey:...

View Article
Browsing latest articles
Browse All 3 View Live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>