# Only if specifically required by your deploymentimport requestsauth_url = "https://vedaya-kge.fly.dev/login"auth_data = { "username": "YOUR_USERNAME", "password": "YOUR_PASSWORD", "grant_type": "password"}response = requests.post(auth_url, data=auth_data)# Note: This endpoint may not be functional in current deployments
Secure access to the Vedaya API (optional for most operations)
Copy
# Only if specifically required by your deploymentimport requestsauth_url = "https://vedaya-kge.fly.dev/login"auth_data = { "username": "YOUR_USERNAME", "password": "YOUR_PASSWORD", "grant_type": "password"}response = requests.post(auth_url, data=auth_data)# Note: This endpoint may not be functional in current deployments
Configure your API connection with environment variables for flexibility:
Copy
import osimport requestsfrom openai import OpenAI# Configure API (prefer environment variables)API_BASE_URL = os.getenv("VEDAYA_API_BASE_URL", "https://vedaya-kge.fly.dev") # no trailing slashAPI_KEY = os.getenv("VEDAYA_API_KEY", "") # leave empty if no auth# Build headersheaders = {"Content-Type": "application/json"}if API_KEY and API_KEY.strip() and API_KEY != "sk-mock-dummy-key": headers["Authorization"] = f"Bearer {API_KEY}"print(f"Connecting to: {API_BASE_URL}")print(f"Auth header set: {'Authorization' in headers}")# Example with real tokenTOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqZWZmQGtub3dkZS5jb20iLCJleHAiOjE3NTY2MDUyNzAsInJvbGUiOiJ1c2VyIiwibWV0YWRhdGEiOnsiYXV0aF9tb2RlIjoiZW5hYmxlZCJ9fQ.3g97xmq8tNRRRSwfqScZog2D-hKt17Fr0AessIMDRx8"# You can also set it directlyAPI_KEY = os.getenv("VEDAYA_API_KEY", TOKEN)
# Only if specifically required by your deploymentimport requestsauth_url = "https://vedaya-kge.fly.dev/login"auth_data = { "username": "YOUR_USERNAME", "password": "YOUR_PASSWORD", "grant_type": "password"}response = requests.post(auth_url, data=auth_data)# Note: This endpoint may not be functional in current deployments
If your specific deployment requires authentication:
Copy
# Optional: Add token to headers if you have oneheaders = {"Content-Type": "application/json"}# Only add auth if you have a real keyif API_KEY and API_KEY.strip() and API_KEY != "sk-mock-dummy-key": headers["Authorization"] = f"Bearer {API_KEY}"# Full example with authenticationresponse = requests.post( f"{API_BASE_URL}/documents/texts", json={"texts": ["Your secure document"]}, headers=headers)