#https platform openai com account api
19 messages · Page 1 of 1 (latest)
I meant, I can not receive the "usage" tag in API JSON response. I received like below{
"id": "cmpl-6nNWEFYgoI4xc4irG384GNjMM28aH",
"object": "text_completion",
"created": 1677226498,
"choices": [
{
"text": "hi,,",
"index": 0,
"logprobs": null,
"finish_reason": "stop"
}
],
"model": "text-davinci-003"
}
I can not found "usage": {
"prompt_tokens": 1,
"completion_tokens": 50,
"total_tokens": 51
}
ah I see, can you show your code for calling this endpoint?
$opts = [
'prompt' => $prompt,
'temperature' => 0,
"max_tokens" => 2048,
"frequency_penalty" => 0,
"presence_penalty" => 0,
"stream" => true,
"top_p" => 1
];
the whole code please
Sorry, too late.
I'm using this php sample code.
@tawny onyx this is because the example uses streaming, so every event will be 1 token
you can keep track yourself that way
but you will have to calculate your input tokens yourself
If you're using PHP I wouldn't recommend using stream mode though
I'd use this client instead: https://github.com/openai-php/client
basically if you want the token usage in the response, don't use stream mode
@deep mango ah.. Thank you very much. I will try it.
no problem, let me know if you have any more issues
so im not a developer or really trying to develop, im looking for for a tool of sorts ive been looking for a long time, wht im trying to do is get my Json files that are from my raw data i want get the waypointpaths , roadsegments ,placeid drwan on a map the only way ive been able to do so is to placeid serch get the geocode then put into maps or earth one at a time if i close the the map all my dots are gone when i go back to it i have thousands ans thousands can you point me in the right direction of better way?
Developers are advised to take precautions when posting code that includes personal API information. Utilizing secure proxy services is strongly recommended for added security.