# Alternative options for API endpoints

**URL:** <https://discuss.huggingface.co/t/alternative-options-for-api-endpoints/153276>\
**Category:** Course\
**Created:** [May 2, 2025, 8:42pm UTC](https://discuss.huggingface.co/t/alternative-options-for-api-endpoints/153276 "2025-05-02T20:42:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pahenn](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pahenn/32/46770_2.png) [@pahenn](https://discuss.huggingface.co/u/pahenn)\
**Post date:** [May 2, 2025, 8:42pm UTC](https://discuss.huggingface.co/t/alternative-options-for-api-endpoints/153276/1 "2025-05-02T20:42:39Z")

</div>

- I just posted in the Discord as well, but figured I’d post over here for those who are only checking one or the other.

Hi all, I have been reading a lot of questions around what to do if the examples for use the `HfApiModel` fail, or you run out of credits. I was in a similar situation, and went down the path of running locally to begin with using the `MLXModel` class and Qwen2.5-Coder-32B, but that was leading to very long waits even with my maxed out M4 Max. So I wanted to share another solution here for anyone in need with lower-end specs or looking for a faster endpoint.

Mistral released Codestral 25.01 in January, and it works great. I switch between using it through Continue.dev in VSCode and Cursor. It really gives Cursor a run for it’s money, and along side that, they created a **free, Codestral-specific API endpoint**. I believe all you need to do is create an account with their Le Plateforme, and you can get a free api key specifically for Codestral chat and completions

```python
api_key = os.getenv("CODESTRAL_API_KEY")
model = OpenAIServerModel(
    model_id="codestral-latest",
    api_base="https://codestral.mistral.ai/v1/",
    api_key=api_key,
)

agent = CodeAgent(tools=[], model=model, add_base_tools=True)
agent.run(
    "Could you give me the 40th number in the Fibonacci sequence?",
)

```

Very snappy, just wanted to share here for those struggling.

---

<div class="post-metadata">

**Author:** ![Aditya175](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aditya175/32/48342_2.png) [@Aditya175](https://discuss.huggingface.co/u/Aditya175)\
**Post date:** [May 28, 2025, 3:31am UTC](https://discuss.huggingface.co/t/alternative-options-for-api-endpoints/153276/2 "2025-05-28T03:31:55Z")

</div>

I tried this solution and it worked like a charm.  
Thank you so much.

---

<div class="post-metadata">

**Author:** ![KiranMSolves](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kiranmsolves/32/50258_2.png) [@KiranMSolves](https://discuss.huggingface.co/u/KiranMSolves)\
**Post date:** [June 28, 2025, 4:01pm UTC](https://discuss.huggingface.co/t/alternative-options-for-api-endpoints/153276/3 "2025-06-28T16:01:27Z")

</div>

This works like a charm awesome help. Thank you so much: [Profile - pahenn - Hugging Face Forums](https://discuss.huggingface.co/u/pahenn)  
And I guess the API link changed to - [https://api.mistral.ai/v1](https://api.mistral.ai/v1)  
Please check if you are using it around my post time.  
And additional note: You have to give your mobile number for an OTP, to subscribe to the Experiment Free tier  
Thanks again

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [July 6, 2025, 11:20am UTC](https://discuss.huggingface.co/t/alternative-options-for-api-endpoints/153276/4 "2025-07-06T11:20:19Z")

</div>

I found this.  
[https://github.com/huggingface/agents-course/issues/281#issuecomment-2765346984](https://github.com/huggingface/agents-course/issues/281#issuecomment-2765346984)

---

<div class="post-metadata">

**Author:** ![pkuang](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pkuang/32/51693_2.png) [@pkuang](https://discuss.huggingface.co/u/pkuang)\
**Post date:** [July 25, 2025, 12:21pm UTC](https://discuss.huggingface.co/t/alternative-options-for-api-endpoints/153276/5 "2025-07-25T12:21:33Z")

</div>

why it is not working for me anymore? I still got the 401 unauthorized error ☹
