Skip to content

Exception: An error occurred while making the request to XAI: Expecting value: line 1 column 1 (char 0) #170

@nnWhisperer

Description

@nnWhisperer

Hi,
I'm trying to run openrouter using base_url approach. I attempted setting the following variables and getting the same error, even after alternating the LLM_PROVIDER to OLLAMA too. Could you please help? I'm using the current latest version(the main branch) of this repo.

XAI_API_KEY was set from OPENROUTER_API_KEY
XAI_BASE_URL was set to https://openrouter.ai/api/v1
LLM_PROVIDER was explicitly set to XAI.
XAI_MODEL is set to google/gemini-3-pro-preview
And the result is:

Progress: 1055/1058 (99%) ... [skipped (excluded)]
Progress: 1056/1058 (99%) ... [skipped (excluded)]
Progress: 1057/1058 (99%) ... [skipped (excluded)]
Progress: 1058/1058 (100%) ...  [skipped (excluded)]
Fetched 932 files.
Identifying abstractions using LLM...
Identifying abstractions using LLM...
Identifying abstractions using LLM...
Identifying abstractions using LLM...
Identifying abstractions using LLM...
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/requests/models.py", line 976, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/Tutorial-Codebase-Knowledge/utils/call_llm.py", line 105, in _call_llm_provider
    response_json = response.json() # Log the response
                    ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/requests/models.py", line 980, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/Tutorial-Codebase-Knowledge/main.py", line 111, in <module>
    main()
  File "/content/Tutorial-Codebase-Knowledge/main.py", line 108, in main
    tutorial_flow.run(shared)
  File "/usr/local/lib/python3.12/dist-packages/pocketflow/__init__.py", line 16, in run
    return self._run(shared)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pocketflow/__init__.py", line 50, in _run
    def _run(self,shared): p=self.prep(shared); o=self._orch(shared); return self.post(shared,p,o)
                                                  ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pocketflow/__init__.py", line 48, in _orch
    while curr: curr.set_params(p); last_action=curr._run(shared); curr=copy.copy(self.get_next_node(curr,last_action))
                                                ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pocketflow/__init__.py", line 13, in _run
    def _run(self,shared): p=self.prep(shared); e=self._exec(p); return self.post(shared,p,e)
                                                  ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pocketflow/__init__.py", line 33, in _exec
    if self.cur_retry==self.max_retries-1: return self.exec_fallback(prep_res,e)
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pocketflow/__init__.py", line 28, in exec_fallback
    def exec_fallback(self,prep_res,exc): raise exc
                                          ^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pocketflow/__init__.py", line 31, in _exec
    try: return self.exec(prep_res)
                ^^^^^^^^^^^^^^^^^^^
  File "/content/Tutorial-Codebase-Knowledge/nodes.py", line 176, in exec
    response = call_llm(prompt, use_cache=(use_cache and self.cur_retry == 0))  # Use cache only if enabled and not retrying
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/Tutorial-Codebase-Knowledge/utils/call_llm.py", line 145, in call_llm
    response_text = _call_llm_provider(prompt)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/Tutorial-Codebase-Knowledge/utils/call_llm.py", line 123, in _call_llm_provider
    raise Exception(f"An error occurred while making the request to {provider}: {e}")
Exception: An error occurred while making the request to XAI: Expecting value: line 1 column 1 (char 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions