Troubleshooting Unstructured API keys and URLs
Issue
When you run script or code to call an Unstructured API, you get one of the following warnings or errors:
You also get the following related warnings or errors in your logs:
Possible causes
- The Unstructured API key, Unstructured API URL, or both are missing or malformed in your script or code.
- The API key, API URL, or both are not present in your current session.
- The API key is no longer valid, or the API key and API URL combination is not valid.
Suggested solutions
For the API URL, note the following:
- For the Unstructured Platform API, the API URL is typically
https://platform.unstructuredapp.io
, which is unique to the Unstructured Python SDK; andhttps://platform.unstructuredapp.io/api/v1
for standard REST-enabled utilities (such ascurl
), tools (such as Postman), programming languages, packages, and libraries. - For the Unstructured Serverless API, the API URL is typically
https://api.unstructuredapp.io
, which is unique to the Unstructured Python SDK, beginning with 0.30.0; andhttps://api.unstructuredapp.io/general/v0/general
for the Unstructured Python SDK before 0.30.0 and for standard REST-enabled utilities (such ascurl
), tools (such as Postman), programming languages, packages, and libraries. Be aware of the inclusion ofapp
in this API URL. - For the Free Unstructured API, the API URL is typically https://api.unstructured.io`, which is unique to
the Unstructured Python SDK, beginning with 0.30.0; and
https://api.unstructured.io/general/v0/general
for the Unstructured Python SDK before 0.30.0 and for standard REST-enabled utilities (such ascurl
), tools (such as Postman), programming languages, packages, and libraries. Be aware that there is noapp
in this API URL.
For the API key, note the following:
-
For the Unstructured Serverless API or the Unstructured Platform API, the API key is in your dashboard. To access your dashboard:
- Sign in to your Unstructured account.
- At the bottom of the sidebar, click your user icon, and then click Account Settings.
- On the API Keys tab, note the value of the Unstructured Serverless API URL or the Unstructured Platform API URL.
Important: For the Unstructured Python SDK beginning with 0.30.0:
- For the Unstructured Platform API URL, do not use
https://platform.unstructuredapp.io/api/v1
, or else calls made by the Python SDK will fail. Usehttps://platform.unstructuredapp.io
instead. - For the Unstructured Serverless API URL, do not use
https://api.unstructuredapp.io/general/v0/general
, or else calls made by the Python SDK will fail. Usehttps://api.unstructuredapp.io
instead. - For the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.
-
For the Free Unstructured API, the API key is in your original email from Unstructured. If you cannot find the original email, you can regenerate it by going to https://unstructured.io/api-key-free.
Important: For the Unstructured Python SDK beginning with 0.30.0,
for the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.
If you still believe you have the correct API URL and API key, try the following steps:
-
Check your script or code to see where the API URL and API key are specified, as follows:
For a POST request to the Unstructured API
- Check the target URL. Make sure it is set to the right API URL.
- Check the value of the
unstructured-api-key
header. Make sure it is set to the right API key, or an environment variable representing the right API key.
For the Unstructured Python SDK (Unstructured Platform API, Unstructured Serverless API, and Free Unstructured API only)
-
For the Unstructured Python SDK beginning with 0.30.0, if the
server_url
parameter is in yourUnstructuredClient
constructor, move it into your operational calling function such aspartition
orpartition_asyc
for Unstructured API services orlist_*
,get_*
,create_*
,update_*
, ordelete_*
for the Unstructured Platform API. For example: -
Check the value of the
server_url
parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL.Important: For the Unstructured Python SDK beginning with 0.30.0:
- For the Unstructured Platform API URL, do not use
https://platform.unstructuredapp.io/api/v1
, or else calls made by the Python SDK will fail. Usehttps://platform.unstructuredapp.io
instead. - For the Unstructured Serverless API URL, do not use
https://api.unstructuredapp.io/general/v0/general
, or else calls made by the Python SDK will fail. Usehttps://api.unstructuredapp.io
instead. - For the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.
- For the Unstructured Platform API URL, do not use
-
Check the value of the
api_key_auth
parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.
For the Unstructured JavaScript/TypeScript SDK (Unstructured Serverless API and Free Unstructured API only)
-
Check the value of the
UnstructuredClient
object’sserverURL
orserver
parameter:-
For
serverURL
, make sure it is set to the right API URL, or an environment variable representing the right API URL, or… -
For
server
, make sure it is set to"saas-api"
for the Unstructured Serverless API, or"free-api"
for the Free Unstructured API, or an environment variable representing one of these strings.You can use"saas-api"
and"free-api"
only with the Unstructured JavaScript/TypeScript SDK. -
Make sure that only
serverURL
orserver
are specified—not both. -
Make sure that if you specify
serverURL
, an actual API URL (or an environment variable representing an actual API URL) is specified (not"saas-api"
or"free-api"
, or an environment variable representing one of these strings). -
Make sure that if you specify
server
, an actual API URL is not specified (it must be only"saas-api"
or"free-api"
, or an environment variable representing one of these strings).
-
-
Check the value of the
UnstructuredClient
object’ssecurity: { apiKeyAuth }
parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.
For the Unstructured Ingest CLI (Unstructured Serverless API and Free Unstructured API only)
- Check the value of the
--partition-endpoint
command option. Make sure it is set to the right API URL, or an environment variable representing the right API URL. - Check the value of the
--api-key
command option. Make sure it is set to the right API key, or an environment variable representing the right API key.
For the Unstructured Ingest Python library (Unstructured Serverless API and Free Unstructured API only)
For a v2 connector implementation, check the value of the
partitioner_config
parameter in thePipeline.from_configs
method. This parameter should be set to aPartitionerConfig
object:- Check the object’s
partition_endpoint
parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL. - Check the object’s
api_key
parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.
For a v1 connector implementation, check the value of the
partition_config
parameter in theRunner
object. This parameter should be set to aPartitionConfig
object:- Check the object’s
partition_endpoint
parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL. - Check the object’s
api_key
parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.
For the Unstructured open source library (Unstructured Serverless API and Free Unstructured API only)
- Check the value of the
partition_by_api
command’sapi_url
parameter. Make sure it is set to the right API URL, or an environment variable representing the right API URL. - Check the value of the
partition_by_api
command’sapi_key
parameter. Make sure it is set to the right API key, or an environment variable representing the right API key.
-
If you follow the recommended approach to use environment variables to represent the API key and API URL instead of hard-coding them into your script or code, check your session to see if these environment variables have been loaded, for example:
- Run the command for your operating system to list all environment variables. Make sure the API key and API URL are listed and are set to the right ones. Make sure the names and cases of these environment variables match the ones in your script or code exactly.
- If you use an integrated development environment (IDE) to run your script or code, check the IDE’s documentation for how to specify and load environment variables at run time or debug time. Make sure the names and cases of these environment variables match the ones in your script or code exactly.
-
Re-verify the API key and API URL that you want to use:
For the Unstructured Serverless API and Unstructured Platform API
-
Sign in to your Unstructured account.
-
At the bottom of the sidebar, click your user icon, and then click Account Settings.
- Make sure that the API key you want to use matches the one in your script, code, or environment variable. To get the full API key value, click the Copy icon. Paste it to a temporary location for you to compare to your the one in your script, code, or environment variable. After you make the comparison, make sure to immediately delete from that temporary location what you just pasted.
- Make sure the Unstructured Serverless API URL or the Unstructured Platform API URL matches the one in your script, code, or environment variable.
Important: For the Unstructured Python SDK beginning with 0.30.0:
- For the Unstructured Platform API URL, do not use
https://platform.unstructuredapp.io/api/v1
, or else calls made by the Python SDK will fail. Usehttps://platform.unstructuredapp.io
instead. - For the Unstructured Serverless API URL, do not use
https://api.unstructuredapp.io/general/v0/general
, or else calls made by the Python SDK will fail. Usehttps://api.unstructuredapp.io
instead.
For the Free Unstructured API
- Open your original email from Unstructured that contains your API key. Make sure it matches the one in your script, code, or environment variable. If you cannot find the original email, you can regenerate it by going to https://unstructured.io/api-key-free.
- Make sure that you are using
https://api.unstructured.io/general/v0/general
(notplatform.unstructuredapp.io
orapi.unstructuredapp.io
) for the API URL.
Important: For the Unstructured Python SDK beginning with 0.30.0 for the Free Unstructured API URL, do not use https://api.unstructured.io/general/v0/general, or else calls made by the Python SDK will fail. Use https://api.unstructured.io` instead.
-
-
If you are still getting this issue, contact us directly.