Troubleshooting Unstructured API keys and API URLs
Issue
When you run script or code to call Unstructured API services, you get the following error:
You also get the following related warning 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 Serverless API, the API URL is typically
https://api.unstructuredapp.io/general/v0/general
(be aware of the inclusion ofapp
in this API URL). - For the Free Unstructured API, the API URL is always
https://api.unstructured.io/general/v0/general
(be aware that there is noapp
in this API URL).
For the API key, note the following:
-
For the Unstructured Serverless API, the API key is in your dashboard. To access your dashboard:
- Sign in to your Unstructured dashboard, at https://app.unstructured.io.
- On the sidebar, click API Keys.
-
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.
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
-
Check the value of the
UnstructuredClient
object’sserver_url
orserver
parameter:-
For
server_url
, 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 SDKs. -
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’sapi_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
-
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 SDKs. -
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
- 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
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
- 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
- Sign in to your Unstructured dashboard, at https://app.unstructured.io.
- On the sidebar, click API Keys.
- 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, and then click Key Only. 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 API URL matches the one in your script, code, or environment variable.
You can use"saas-api"
with the Unstructured SDKs, instead of an API URL. For more information, see Item 1 earlier in this section.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
(notapi.unstructuredapp.io
) for the API URL.
You can use"free-api"
with the Unstructured SDKs, instead of an API URL. For more information, see Item 1 earlier in this section. -
If you are still getting this issue, contact Support by clicking the Support icon in the sidebar, or by emailing support@unstructured.io.
Was this page helpful?