<?php
namespace boru\boruai\Openai\Api\Responses;

class ChatCompletionResponse extends ApiBaseResponse {
    public function id() {
        return $this->get("id",false);
    }
    public function object() {
        return $this->get("object",false);
    }
    public function created() {
        return $this->get("created",false);
    }
    public function model() {
        return $this->get("model",false);
    }
    public function usage() {
        return $this->get("usage",false);
    }
    public function usagePrompt() {
        return $this->get("usage.prompt_tokens",0);
    }
    public function usageCompletion() {
        return $this->get("usage.completion_tokens",0);
    }
    public function usageTotal() {
        return $this->get("usage.total_tokens",0);
    }
    public function choices() {
        return $this->get("choices",false);
    }
    public function choice($k=0) {
        if($k < 0) {
            return $this->body;
        }
        if(isset($this->body["choices"][$k])) {
            return $this->body["choices"][$k];
        }
        return false;
    }
}