Views
No views yet
data = {
"model": model,
"messages": [
{"role": "system", "content": "You are an expert career coach and ATS resume optimizer."},
{"role": "user", "content": prompt}
]
}
response = requests.post("https://openrouter.ai/api/v1/chat/completions", headers=headers, json=data)
try:
response.raise_for_status()
response_json = response.json()
if "choices" not in response_json:
return f"Error: 'choices' not found. Message: {response_json.get('error', 'Unknown error')}"
return response_json["choices"][0]["message"]["content"]
except requests.exceptions.HTTPError as e:
return f"HTTP Error: {e}\nResponse: {response.text}"
except Exception as e:
return f"Unexpected Error: {e}"