data-formulator icon indicating copy to clipboard operation
data-formulator copied to clipboard

Can't use Openrouter with openai/chatgpt-4o

Open ericchaves opened this issue 9 months ago • 4 comments

Hi folks, congrats for sharing this great project with the world!!

I'd like to try data formulator using open router as the API provider. I'm running DF using a basic docker container. When I try to add setup the model provider, it looks like it try to validate the key format, and therefore does not accept the OpenRouter key.

Any hints or help would be much appreciated. Thanks in advance.

Image

FROM python:3

WORKDIR /usr/src/app

RUN apt update -y && pip install --upgrade pip

RUN pip install --no-cache-dir data_formulator

CMD [ "python", "-m", "data_formulator" ]

ericchaves avatar Apr 04 '25 19:04 ericchaves

Looking at the docs from OpenRouter (https://openrouter.ai/docs/quickstart#using-the-openai-sdk), it looks like we need both api_key and models?

I'm wondering what happens if you provide keys (sk-or-v1xxxxxxxxxcxx) and models (openai/chatgpt-4o-latest) and api_base (https://openrouter.ai/api/v1) all together? Seems like the first two you omitted key and the latter one model name isn't there?

Chenglong-MS avatar Apr 04 '25 21:04 Chenglong-MS

@Chenglong-MS I provided both. What I could notice is that once I input the openrouter api key, the input box becomes outlined in red (the outline in the screenshot comes from data-framework, only the key redaction was added by me), which makes me believe that the inputbox is doing some kind of format/regex validation and is finding it incompatible with openai keys.

Once I hit the "+" (plus button) the line is "inserted" above the input boxes but with the api key in blank and the error message "api_key".

In all attepmpts I provided the following fields:

  • provider: always "openai"
  • api_key: always provided my open router api key
  • model: tried multiple openrouter models including some sintax variations (just to see if it would work) like google/gemini-2.0-flash-thinking-exp:free, google/gemini-2.0-flash-thinking-exp, gemini-2.0-flash-thinking-exp
  • *base_url: tried https://openrouter.ai/api/v1, https://openrouter.ai/api/v1/chat/completions and https://openrouter.ai/api/v1/completions
  • api_version: left blank

This same open router key was successfully used in another projects.

ericchaves avatar Apr 05 '25 02:04 ericchaves

Thanks for the info! It looks like a bug, let me take a look.


From: Eric Paschoalick Chaves @.> Sent: Friday, April 4, 2025 7:01:50 PM To: microsoft/data-formulator @.> Cc: Mention @.>; Comment @.>; Subscribed @.***> Subject: Re: [microsoft/data-formulator] Can't use Openrouter with openai/chatgpt-4o (Issue #143)

@Chenglong-MShttps://github.com/Chenglong-MS I provided both. What I could notice is that once I input the openrouter api key, the input box becomes outlined in red (the outline in the screenshot comes from data-framework, only the key redaction was added by me), which makes me believe that the inputbox is doing some kind of format/regex validation and is finding it incompatible with openai keys.

Once I hit the "+" (plus button) the line is "inserted" above the input boxes but with the api key in blank and the error message "api_key".

In all attepmpts I provided the following fields:

  • provider: always "openai"
  • api_key: always provided my open router api key
  • model: tried multiple openrouter models including some sintax variations (just to see if it would work) like google/gemini-2.0-flash-thinking-exp:free, google/gemini-2.0-flash-thinking-exp, gemini-2.0-flash-thinking-exp
  • *base_url: tried https://openrouter.ai/api/v1, https://openrouter.ai/api/v1/chat/completions and https://openrouter.ai/api/v1/completions
  • api_version: left blank

This same open router key was successfully used in another projects.

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/data-formulator/issues/143#issuecomment-2780133708 or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWJXEPGLOQMHWAZH2E7CWYL2X42Q7BFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLLDTOVRGUZLDORPXI6LQMWWES43TOVSUG33NNVSW45FGORXXA2LDOOJIFJDUPFYGLKTSMVYG643JORXXE6NFOZQWY5LFVE4DCMRQG43TMMRRQKSHI6LQMWSWS43TOVS2K5TBNR2WLKRSHE3TGMRTGQ3DQMVHORZGSZ3HMVZKMY3SMVQXIZI. You are receiving this email because you were mentioned.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Chenglong-MS avatar Apr 05 '25 03:04 Chenglong-MS

Sorry for the delay because of recent work on the database support (https://github.com/microsoft/data-formulator/releases/tag/0.2).

It should be fixe now! If you pip install --upgrade data_formulator, it will update to v0.2.1.1. It would support using openAI API for other endpoints (e.g., ollama, openrouter)

Example:

Image

Chenglong-MS avatar Apr 25 '25 00:04 Chenglong-MS