any thoughts on getting this model added - xAI: Gr...
# general
f
any thoughts on getting this model added - xAI: Grok Code Fast 1
b
You should be able to use any model as long as it is supported by litellm. You can toggle the
Advanced
settings under
LLM
and then put the custom model along with the prefix. If you do that and it still doesn't work, please open a github issue.
f
can i get a few more details on how this would work - is there a note the the documentation about it
b
Check out this doc: https://docs.litellm.ai/docs/providers/xai So it’ll be like: xai/grok-code-fast-1
So you go to settings -> LLM. Toggle Advanced. Then in custom model put that. And then your API key for xai in the api key textbox
Then it should theoretically work
f
cheers appreciate
the quick reply
i will give it a go
like this -
image.png
Using 1 stdio MCP servers, 0 SSE MCP servers and 0 SHTTP MCP servers. What do you want to build? Type /help for help
can you tell me if the c++ project is correct in regards to the api connector
125011 - openhandsERROR agent_controller.py:365 - [Agent Controller 5c7a29fc-d7c1-48-89974dfb317c2cc] Error while running the agent (session ID: 5c7a29fc-d7c1-48-89974dfb317c2cc): litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=x-ai/grok-code-fast-1 Pass model as E.g. For 'Huggingface' inference endpoints pass in
completion(model='huggingface/starcoder',..)
Learn more: https://docs.litellm.ai/docs/providers. Traceback: Traceback (most recent call last): File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/openhands/controller/agent_controller.py", line 363, in _step_with_exception_handling await self._step() File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/openhands/controller/agent_controller.py", line 917, in _step raise e File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/openhands/controller/agent_controller.py", line 870, in _step action = self.agent.step(self.state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/openhands/agenthub/codeact_agent/codeact_agent.py", line 215, in step response = self.llm.completion(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/tenacity/__init__.py", line 338, in wrapped_f return copy(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/tenacity/__init__.py", line 477, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/tenacity/__init__.py", line 378, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/tenacity/__init__.py", line 400, in <lambda> self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/tenacity/__init__.py", line 480, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/openhands/llm/llm.py", line 328, in wrapper resp: ModelResponse = self._completion_unwrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/litellm/utils.py", line 1344, in wrapper raise e File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/litellm/utils.py", line 1219, in wrapper result = original_function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/litellm/main.py", line 3494, in completion raise exception_type( File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/litellm/main.py", line 1103, in completion model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( ^^^^^^^^^^^^^^^^^ File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py", line 401, in get_llm_provider raise e File "/home/andrewcz/OpenHands/.venv/lib64/python3.12/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py", line 378, in get_llm_provider raise litellm.exceptions.BadRequestError( # type: ignore litellm.exceptions.BadRequestError: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=x-ai/grok-code-fast-1 Pass model as E.g. For 'Huggingface' inference endpoints pass in
completion(model='huggingface/starcoder',..)
Learn more: https://docs.litellm.ai/docs/providers 125011 - openhandsERROR loop.py:24 - BadRequestError: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=x-ai/grok-code-fast-1 Pass model as E.g. For 'Huggingface' inference endpoints pass in
completion(model='huggingface/starcoder',..)
Learn more: https://docs.litellm.ai/docs/providers Agent running... (Press Ctrl-P to pause) ⚠️ Session was interrupted: error
Excellent, you've solved the previous error, and now we have a new, more specific one. This is great progress! This error is actually much better because it shows that you are successfully connecting to OpenRouter, and the provider (xAI) is responding. Let's break down exactly what this new error means. The Problem: A Model-Specific Incompatibility The key to the entire error log is this one line from the provider: code JSON
Copy code
{
  "code": "Client specified an invalid argument",
  "error": "Argument not supported on this model: stop"
}
Here’s what this means in simple terms: 1. OpenHands, by default, sends a parameter called
stop
in its API request to the LLM. This parameter is used to tell the model when to stop generating text (e.g., stop when you see the word "Human:"). 2. However, the specific model you've chosen (
x-ai/grok-code-fast-1
) does not support this
stop
parameter
. 3. When the xAI server receives the request with this unsupported argument, it correctly rejects it with a "400 Bad Request" error. This is not a bug in your setup but rather a compatibility issue between the default behavior of OpenHands and the specific API requirements of that particular Grok model. The Easiest Solution: Switch to a More Compatible Model The most reliable and straightforward way to fix this is to switch to a different high-quality model on OpenRouter that is known to be fully compatible with the standard API parameters that OpenHands uses. A fantastic, powerful, and free option for coding on OpenRouter is Nous Hermes 2 Pro on Llama 3. It's highly capable and follows the standard API conventions. Step-by-Step Instructions to Fix It 1. Start OpenHands again. 2. code Bash 3. 1. IGNORE_WHEN_COPYING_START 2. IGNORE_WHEN_COPYING_END 3. 4. openhands 5. 6. Go back into the settings. 7. code Code 8. 1. IGNORE_WHEN_COPYING_START 2. IGNORE_WHEN_COPYING_END 3. 4. > /settings 5. 6. Navigate to the Advanced LLM settings. ◦ Select
LLM (Advanced)
and press Enter. 7. Enter the New, Compatible Model Name. • At the first prompt, enter the following model name exactly as written: • code Code • • IGNORE_WHEN_COPYING_START • IGNORE_WHEN_COPYING_END • • (Step 1/6) Custom Model (CTRL-c to cancel): openrouter/nousresearch/nous-hermes-2-llama-3-8b • ◦ 1. Confirm Your Other Settings. ◦ Your other settings (Base URL:
https://openrouter.ai/api/v1
, your API key, etc.) are all correct. You should be able to press
Enter
on each of the following steps to accept the current values. 2. Save, Exit, and Restart. ◦ Save the new settings when prompted. ◦ Exit OpenHands with
/exit
. ◦ Start
openhands
one last time. Now, OpenHands will send its requests to a model that fully supports all of its features. Test with a Simple Prompt Once you've restarted, test it with a clear, simple task to ensure everything is working:
Read the file
src/BinanceConnector.cpp
and list the names of all the public methods in the
BinanceConnector
class.
This will confirm that the agent can read your files and the LLM connection is fully operational.
it seems like the stop parameter is causing the issue
has not been updated for the command line interface
b
Looks like you're running into this issue? https://github.com/All-Hands-AI/OpenHands/issues/10729