llm=google.LLM(model="gemini-2.5-flash",temperatur...
# ask-ai
r
llm=google.LLM(model="gemini-2.5-flash",temperature=0.3,max_completion_tokens=200), how to set max token number. this way not wokring Traceback (most recent call last): File "C:\Users\ASUS TUF\Desktop\works\123 livekit\.venv\Lib\site-packages\opentelemetry\util\_decorator.py", line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ASUS TUF\Desktop\works\123 livekit\.venv\Lib\site-packages\livekit\agents\ipc\job_proc_lazy_main.py", line 240, in _traceable_entrypoint await self._job_entrypoint_fnc(job_ctx) File "C:\Users\ASUS TUF\Desktop\works\123 livekit\src\pay_go\pay_go_agent.py", line 1011, in entrypoint llm=google.LLM(model="gemini-2.5-flash",temperature=0.3,max_completion_tokens=200), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: LLM.__init__() got an unexpected keyword argument 'max_completion_tokens' {"message": "unhandled exception while running the job task", "level": "ERROR", "name": "livekit.agents", "exc_info": "Traceback (most recent call last):\n File \"C:\\Users\\ASUS TUF\\Desktop\\works\\123 livekit\\.venv\\Lib\\site-packages\\opentelemetry\\util\\_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"C:\\Users\\ASUS TUF\\Desktop\\works\\123 livekit\\.venv\\Lib\\site-packages\\livekit\\agents\\ipc\\job_proc_lazy_main.py\", line 240, in _traceable_entrypoint\n await self._job_entrypoint_fnc(job_ctx)\n File \"C:\\Users\\ASUS TUF\\Desktop\\works\\123 livekit\\src\\pay_go\\pay_go_agent.py\", line 1011, in entrypoint\n llm=google.LLM(model=\"gemini-2.5-flash\",temperature=0.3,max_completion_tokens=200),\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: LLM.__init__() got an unexpected keyword argument 'max_completion_tokens'", "timestamp": "2025-09-10T051609.369215+00:00"} [2025-09-10 104609,377] INFO livekit.agents: initializing job runner {"message": "initializing job runner", "level": "INFO", "name": "livekit.agents", "tid": 26472, "timestamp": "2025-09-10T051609.377393+00:00"} [2025-09-10 104609,491] INFO livekit.agents: job runner initialized {"message": "job runner initialized", "level": "INFO", "name": "livekit.agents", "tid": 26472, "elapsed_time": 0.11, "timestamp": "2025-09-10T051609.491031+00:00"}
t
Thanks for reaching out, Av. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like the error happened because
max_completion_tokens
isn’t a valid parameter for the
google.LLM
class. No worries though! To set the maximum token limit, you’ll want to use the
max_output_tokens
parameter instead. Here’s a quick example to help you out:
Copy code
from livekit.plugins import google

llm_instance = google.LLM(
    model="gemini-2.5-flash",
    temperature=0.3,
    max_output_tokens=200  # Replace with your desired token limit
)
Just swap out
max_completion_tokens
for
max_output_tokens
in your code, and everything should work smoothly. If you have any more questions, feel free to ask—I’m here to help! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | plugins/openai/src/llm.ts | Google integration guide | LiveKit Docs | agent/main.py