Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files1LANGFLOW_API_KEY= “sk-9YX9IbKBPulcM2-tDjm9v5TnoK0R637Jyq_Q9R6AD9w”123456789101112131415161718192021222324252627282930313233343536import requests
import os
# API Configuration
try:
api_key = os.environ["LANGFLOW_API_KEY"]
except KeyError:
raise ValueError("LANGFLOW_API_KEY environment variable not found. Please set your API key in the environment variables.")
url = "http://localhost:7860/api/v1/run/98a1a81b-80b4-4d51-adc9-b72756e3983b" # The complete API endpoint URL for this flow
# Request payload configuration
payload = {
"output_type": "chat",
"input_type": "chat",
"input_value": "hello world!"
}
# Request headers
headers = {
"Content-Type": "application/json",
"x-api-key": api_key # Authentication key from environment variable
}
try:
# Send API request
response = requests.request("POST", url, json=payload, headers=headers)
response.raise_for_status() # Raise exception for bad status codes
# Print response
print(response.text)
except requests.exceptions.RequestException as e:
print(f"Error making API request: {e}")
except ValueError as e:
print(f"Error parsing response: {e}").envAdded+1
app.pyAdded+36