error when running the sample code from the langchain documentation about fireworks
Labels: name: auto:bug, name: area: models

### System Info

I used the standard code example from the langchain documentation about Fireworks where I inserted my API key. That's the mistake I made:
```
[llm/start] [1:llm:Fireworks] Entering LLM run with input:
{
  "prompts": [
    "Name 3 sports."
  ]
}
[llm/error] [1:llm:Fireworks] [761ms] LLM run errored with error:
"AuthenticationError({'fault': {'faultstring': 'Invalid ApiKey', 'detail': {'errorcode': 'oauth.v2.InvalidApiKey'}}})Traceback (most recent call last):\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain_core\\language_models\\llms.py\", line 540, in _generate_helper\n    self._generate(\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain_community\\llms\\fireworks.py\", line 100, in _generate\n    response = completion_with_retry_batching(\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain_community\\llms\\fireworks.py\", line 296, in completion_with_retry_batching\n    return batch_sync_run()\n           ^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain_community\\llms\\fireworks.py\", line 293, in batch_sync_run\n    results = list(executor.map(_completion_with_retry, prompt))\n              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Program Files\\Python311\\Lib\\concurrent\\futures\\_base.py\", line 619, in result_iterator\n    yield _result_or_cancel(fs.pop())\n          ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Program Files\\Python311\\Lib\\concurrent\\futures\\_base.py\", line 317, in _result_or_cancel\n    return fut.result(timeout)\n           ^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Program Files\\Python311\\Lib\\concurrent\\futures\\_base.py\", line 456, in result\n    return self.__get_result()\n           ^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Program Files\\Python311\\Lib\\concurrent\\futures\\_base.py\", line 401, in __get_result\n    raise self._exception\n\n\n  File \"C:\\Program Files\\Python311\\Lib\\concurrent\\futures\\thread.py\", line 58, in run\n    result = self.fn(*self.args, **self.kwargs)\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\tenacity\\__init__.py\", line 289, in wrapped_f\n    return self(f, *args, **kw)\n           ^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\tenacity\\__init__.py\", line 379, in __call__\n    do = self.iter(retry_state=retry_state)\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\tenacity\\__init__.py\", line 314, in iter\n    return fut.result()\n           ^^^^^^^^^^^^\n\n\n  File \"C:\\Program Files\\Python311\\Lib\\concurrent\\futures\\_base.py\", line 449, in result\n    return self.__get_result()\n           ^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Program Files\\Python311\\Lib\\concurrent\\futures\\_base.py\", line 401, in __get_result\n    raise self._exception\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\tenacity\\__init__.py\", line 382, in __call__\n    result = fn(*args, **kwargs)\n             ^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain_community\\llms\\fireworks.py\", line 289, in _completion_with_retry\n    return fireworks.client.Completion.create(**kwargs, prompt=prompt)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\fireworks\\client\\base_completion.py\", line 80, in create\n    return cls._create_non_streaming(\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\fireworks\\client\\base_completion.py\", line 158, in _create_non_streaming\n    response = client.post_request_non_streaming(\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\fireworks\\client\\api_client.py\", line 125, in post_request_non_streaming\n    self._error_handling(response)\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\fireworks\\client\\api_client.py\", line 91, in _error_handling\n    self._raise_for_status(resp)\n\n\n  File \"C:\\Users\\akidra\\AppData\\Roaming\\Python\\Python311\\site-packages\\fireworks\\client\\api_client.py\", line 67, in _raise_for_status\n    raise AuthenticationError(resp.json())\n\n\nfireworks.client.error.AuthenticationError: {'fault': {'faultstring': 'Invalid ApiKey', 'detail': {'errorcode': 'oauth.v2.InvalidApiKey'}}}"
---------------------------------------------------------------------------
AuthenticationError                       Traceback (most recent call last)
Cell In[25], line 7
      1 from langchain.llms.fireworks import Fireworks 
      3 llm = Fireworks(
      4     fireworks_api_key="<BPR7ILI5ar0xAVWKwwAPvE8cyL2yBFpJRGqDGU3QirD6N8W0>",
      5     model="accounts/fireworks/models/mixtral-8x7b-instruct",
      6     max_tokens=256)
----> 7 llm("Name 3 sports.")

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\language_models\llms.py:892, in BaseLLM.__call__(self, prompt, stop, callbacks, tags, metadata, **kwargs)
    885 if not isinstance(prompt, str):
    886     raise ValueError(
    887         "Argument `prompt` is expected to be a string. Instead found "
    888         f"{type(prompt)}. If you want to run the LLM on multiple prompts, use "
    889         "`generate` instead."
    890     )
    891 return (
--> 892     self.generate(
    893         [prompt],
    894         stop=stop,
    895         callbacks=callbacks,
    896         tags=tags,
    897         metadata=metadata,
    898         **kwargs,
    899     )
    900     .generations[0][0]
    901     .text
    902 )

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\language_models\llms.py:666, in BaseLLM.generate(self, prompts, stop, callbacks, tags, metadata, run_name, **kwargs)
    650         raise ValueError(
    651             "Asked to cache, but no cache found at `langchain.cache`."
    652         )
    653     run_managers = [
    654         callback_manager.on_llm_start(
    655             dumpd(self),
   (...)
    664         )
    665     ]
--> 666     output = self._generate_helper(
    667         prompts, stop, run_managers, bool(new_arg_supported), **kwargs
    668     )
    669     return output
    670 if len(missing_prompts) > 0:

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\language_models\llms.py:553, in BaseLLM._generate_helper(self, prompts, stop, run_managers, new_arg_supported, **kwargs)
    551     for run_manager in run_managers:
    552         run_manager.on_llm_error(e, response=LLMResult(generations=[]))
--> 553     raise e
    554 flattened_outputs = output.flatten()
    555 for manager, flattened_output in zip(run_managers, flattened_outputs):

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\language_models\llms.py:540, in BaseLLM._generate_helper(self, prompts, stop, run_managers, new_arg_supported, **kwargs)
    530 def _generate_helper(
    531     self,
    532     prompts: List[str],
   (...)
    536     **kwargs: Any,
    537 ) -> LLMResult:
    538     try:
    539         output = (
--> 540             self._generate(
    541                 prompts,
    542                 stop=stop,
    543                 # TODO: support multiple run managers
    544                 run_manager=run_managers[0] if run_managers else None,
    545                 **kwargs,
    546             )
    547             if new_arg_supported
    548             else self._generate(prompts, stop=stop)
    549         )
    550     except BaseException as e:
    551         for run_manager in run_managers:

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_community\llms\fireworks.py:100, in Fireworks._generate(self, prompts, stop, run_manager, **kwargs)
     98 choices = []
     99 for _prompts in sub_prompts:
--> 100     response = completion_with_retry_batching(
    101         self,
    102         self.use_retry,
    103         prompt=_prompts,
    104         run_manager=run_manager,
    105         stop=stop,
    106         **params,
    107     )
    108     choices.extend(response)
    110 return self.create_llm_result(choices, prompts)

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_community\llms\fireworks.py:296, in completion_with_retry_batching(llm, use_retry, run_manager, **kwargs)
    293         results = list(executor.map(_completion_with_retry, prompt))
    294     return results
--> 296 return batch_sync_run()

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_community\llms\fireworks.py:293, in completion_with_retry_batching.<locals>.batch_sync_run()
    291 def batch_sync_run() -> List:
    292     with ThreadPoolExecutor() as executor:
--> 293         results = list(executor.map(_completion_with_retry, prompt))
    294     return results

File C:\Program Files\Python311\Lib\concurrent\futures\_base.py:619, in Executor.map.<locals>.result_iterator()
    616 while fs:
    617     # Careful not to keep a reference to the popped future
    618     if timeout is None:
--> 619         yield _result_or_cancel(fs.pop())
    620     else:
    621         yield _result_or_cancel(fs.pop(), end_time - time.monotonic())

File C:\Program Files\Python311\Lib\concurrent\futures\_base.py:317, in _result_or_cancel(***failed resolving arguments***)
    315 try:
    316     try:
--> 317         return fut.result(timeout)
    318     finally:
    319         fut.cancel()

File C:\Program Files\Python311\Lib\concurrent\futures\_base.py:456, in Future.result(self, timeout)
    454     raise CancelledError()
    455 elif self._state == FINISHED:
--> 456     return self.__get_result()
    457 else:
    458     raise TimeoutError()

File C:\Program Files\Python311\Lib\concurrent\futures\_base.py:401, in Future.__get_result(self)
    399 if self._exception:
    400     try:
--> 401         raise self._exception
    402     finally:
    403         # Break a reference cycle with the exception in self._exception
    404         self = None

File C:\Program Files\Python311\Lib\concurrent\futures\thread.py:58, in _WorkItem.run(self)
     55     return
     57 try:
---> 58     result = self.fn(*self.args, **self.kwargs)
     59 except BaseException as exc:
     60     self.future.set_exception(exc)

File ~\AppData\Roaming\Python\Python311\site-packages\tenacity\__init__.py:289, in BaseRetrying.wraps.<locals>.wrapped_f(*args, **kw)
    287 @functools.wraps(f)
    288 def wrapped_f(*args: t.Any, **kw: t.Any) -> t.Any:
--> 289     return self(f, *args, **kw)

File ~\AppData\Roaming\Python\Python311\site-packages\tenacity\__init__.py:379, in Retrying.__call__(self, fn, *args, **kwargs)
    377 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
    378 while True:
--> 379     do = self.iter(retry_state=retry_state)
    380     if isinstance(do, DoAttempt):
    381         try:

File ~\AppData\Roaming\Python\Python311\site-packages\tenacity\__init__.py:314, in BaseRetrying.iter(self, retry_state)
    312 is_explicit_retry = fut.failed and isinstance(fut.exception(), TryAgain)
    313 if not (is_explicit_retry or self.retry(retry_state)):
--> 314     return fut.result()
    316 if self.after is not None:
    317     self.after(retry_state)

File C:\Program Files\Python311\Lib\concurrent\futures\_base.py:449, in Future.result(self, timeout)
    447     raise CancelledError()
    448 elif self._state == FINISHED:
--> 449     return self.__get_result()
    451 self._condition.wait(timeout)
    453 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:

File C:\Program Files\Python311\Lib\concurrent\futures\_base.py:401, in Future.__get_result(self)
    399 if self._exception:
    400     try:
--> 401         raise self._exception
    402     finally:
    403         # Break a reference cycle with the exception in self._exception
    404         self = None

File ~\AppData\Roaming\Python\Python311\site-packages\tenacity\__init__.py:382, in Retrying.__call__(self, fn, *args, **kwargs)
    380 if isinstance(do, DoAttempt):
    381     try:
--> 382         result = fn(*args, **kwargs)
    383     except BaseException:  # noqa: B902
    384         retry_state.set_exception(sys.exc_info())  # type: ignore[arg-type]

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_community\llms\fireworks.py:289, in completion_with_retry_batching.<locals>._completion_with_retry(prompt)
    287 @conditional_decorator(use_retry, retry_decorator)
    288 def _completion_with_retry(prompt: str) -> Any:
--> 289     return fireworks.client.Completion.create(**kwargs, prompt=prompt)

File ~\AppData\Roaming\Python\Python311\site-packages\fireworks\client\base_completion.py:80, in BaseCompletion.create(cls, model, prompt_or_messages, request_timeout, stream, client, **kwargs)
     76     return cls._create_streaming(
     77         model, request_timeout, client=client, **kwargs
     78     )
     79 else:
---> 80     return cls._create_non_streaming(
     81         model, request_timeout, client=client, **kwargs
     82     )

File ~\AppData\Roaming\Python\Python311\site-packages\fireworks\client\base_completion.py:158, in BaseCompletion._create_non_streaming(cls, model, request_timeout, client, **kwargs)
    156 client = client or FireworksClient(request_timeout=request_timeout)
    157 data = {"model": model, "stream": False, **kwargs}
--> 158 response = client.post_request_non_streaming(
    159     f"{client.base_url}/{cls.endpoint}", data=data
    160 )
    161 return cls.response_class(**response)

File ~\AppData\Roaming\Python\Python311\site-packages\fireworks\client\api_client.py:125, in FireworksClient.post_request_non_streaming(self, url, data)
    119 with httpx.Client(
    120     headers={"Authorization": f"Bearer {self.api_key}"},
    121     timeout=self.request_timeout,
    122     **self.client_kwargs,
    123 ) as client:
    124     response = client.post(url, json=data)
--> 125     self._error_handling(response)
    126     return response.json()

File ~\AppData\Roaming\Python\Python311\site-packages\fireworks\client\api_client.py:91, in FireworksClient._error_handling(self, resp)
     89 if resp.is_error:
     90     resp.read()
---> 91 self._raise_for_status(resp)

File ~\AppData\Roaming\Python\Python311\site-packages\fireworks\client\api_client.py:67, in FireworksClient._raise_for_status(self, resp)
     65     raise InvalidRequestError(resp.json())
     66 elif resp.status_code == 401:
---> 67     raise AuthenticationError(resp.json())
     68 elif resp.status_code == 403:
     69     raise PermissionError(resp.json())

AuthenticationError: {'fault': {'faultstring': 'Invalid ApiKey', 'detail': {'errorcode': 'oauth.v2.InvalidApiKey'}}}
```

### Who can help?

@eyurtsev

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

1. i use https://python.langchain.com/docs/integrations/providers/fireworks
2. got the API key in https://app.fireworks.ai/api-keys
3. I inserted my key into this code:
```
from langchain.llms.fireworks import Fireworks
import os

os.environ["FIREWORKS_API_KEY"] = "<My key was here.>"
llm = Fireworks(fireworks_api_key="<My key was here.>")

llm = Fireworks(
    fireworks_api_key="<My key was here.>",
    model="accounts/fireworks/models/mixtral-8x7b-instruct",
    max_tokens=256)
llm("Name 3 sports.")
```

### Expected behavior

this example is from the documentation - I just want it to work to move on.