You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Global variables are not applied in API KEY field of open ai chat & embeddings components when calling workflows via API
Works properly in the editor playground
Global variable is properly set as a credential
Reproduction
Create a workflow that contains OpenAI chat component with the key value set from a global variable
Call the workflow via CURL
Error message:
❯ curl -X POST \
"[REDACTED]/api/v1/run/7209dd18-ca3f-47ad-bf81-5e65f7dd5e7e?stream=false" \
-H 'Content-Type: application/json'\
-H 'x-api-key: [REDACTED]'\
-d '{"input_value": "what is this document about",
"output_type": "chat",
"input_type": "chat"}'
{"detail":"{\"message\":\"Error running graph: Error building Component OpenAI: \\n\\nError code: 401 - {'error': {'message': \\\"Authentication Error, LiteLLM Virtual Key expected. Received=dummy, expected to start with 'sk-'.\\\", 'type': 'auth_error', 'param': 'None', 'code': '401'}}\",\"traceback\":null,\"description\":null,\"code\":null,\"suggestion\":null}"}%
Replace the global variable in the openai component's API key field with a raw value
Call the curl again
❯ curl -X POST \
"[REDACTED]/api/v1/run/7209dd18-ca3f-47ad-bf81-5e65f7dd5e7e?stream=false" \
-H 'Content-Type: application/json'\
-H 'x-api-key: [REDACTED]'\
-d '{"input_value": "what is this document about",
"output_type": "chat",
"input_type": "chat"}'
{"session_id":"7209dd18-ca3f-47ad-bf81-5e65f7dd5e7e","outputs":[{"inputs":{"input_value":"what is this document about"},"outputs":[{"results":{"message":{"text_key":"text","data":{"timestamp":"2025-02-11T17:13:25+00:00","sender":"Machine","sender_name":"AI","session_id":"7209dd18-ca3f-47ad-bf81-5e65f7dd5e7e","text":"This document is a ...
Expected behavior
The call should succeed when using a global variable in the API key field of Open AI component
Who can help?
No response
Operating System
Docker deployment
Langflow Version
1.1.4.post1
Python Version
None
Screenshot
No response
Flow File
No response
The text was updated successfully, but these errors were encountered:
avatsaev
changed the title
Global variables in API key field not working properly when called via cURL
Global variables in API key field of OpenAi component not working properly when called via cURL
Feb 11, 2025
Hello @avatsaev! I'm here to help you with any bugs, questions, or contributions you have. Let's work together to solve the issue you're facing!
It seems that there is an issue with global variables not being applied correctly in the API key field of the OpenAI component when workflows are called via cURL in Langflow version 1.1.4.post1. This results in an authentication error.
To address this, you might want to check the following:
Global Variable Configuration: Ensure that the global variable for the OpenAI API key is correctly configured and saved in the Langflow UI. Verify that it is of type Credential and that it is applied to the correct field.
Environment Variables: If you are using environment variables to set global variables, make sure that LANGFLOW_STORE_ENVIRONMENT_VARIABLES is set to true in your .env file, and that the variable OPENAI_API_KEY is included in LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT[1].
Encryption and Decryption: Ensure that the LANGFLOW_SECRET_KEY is correctly set and consistent across your deployment, as it is used for encrypting and decrypting global variables [1][2].
If these steps do not resolve the issue, it might be necessary to investigate further into how global variables are being substituted in API requests, as there might be a bug in the current implementation.
Bug Description
Global variables are not applied in API KEY field of open ai chat & embeddings components when calling workflows via API
Works properly in the editor playground
Global variable is properly set as a credential
Reproduction
Error message:
Expected behavior
The call should succeed when using a global variable in the API key field of Open AI component
Who can help?
No response
Operating System
Docker deployment
Langflow Version
1.1.4.post1
Python Version
None
Screenshot
No response
Flow File
No response
The text was updated successfully, but these errors were encountered: