Sure,
client = OpenAI(
api_key=userdata.get('OPENAI_API_KEY'),
base_url=PORTKEY_GATEWAY_URL,
default_headers=createHeaders(
provider="openai",
api_key=userdata.get('PORTKEY_API_KEY_2'),
config="pc-assist-f3c8b9"
)
)
file = client.files.create(file=open("prompt-partials.pdf", "rb"),purpose="assistants")
file_id = file.id
print(file_id)
Error I see:
APIStatusError Traceback (most recent call last)
<ipython-input-30-b038bb4b1448> in <cell line: 1>()
----> 1 client.files.create(
2 file=open("document.pdf", "rb"),
3 purpose="fine-tune"
4 )
5
3 frames
/usr/local/lib/python3.10/dist-packages/openai/_base_client.py in _request(self, cast_to, options, remaining_retries, stream, stream_cls)
1010
1011 log.debug("Re-raising status error")
-> 1012 raise self._make_status_error_from_response(err.response) from None
1013
1014 return self._process_response(
APIStatusError: Error code: 415 - {'error': {'message': "Invalid Content-Type header (application/json), expected multipart/form-data. (HINT: If you're using curl, you can pass -H 'Content-Type: multipart/form-data')", 'type': 'invalid_request_error', 'param': None, 'code': None}}