> ## Documentation Index
> Fetch the complete documentation index at: https://docs.expectedparrot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Model access and API keys

> Choose hosted execution or direct provider access, and configure credentials.

Constructing questions, surveys, and other objects does not require credentials. Generating responses requires access to the selected model. The test model used in the [Run your first survey](https://docs.expectedparrot.com/en/latest/starter_tutorial.md) tutorial runs locally without credentials or paid calls.

## Choose an execution path

| Path | Credentials | Execution |
| - | - | - |
| Expected Parrot hosted execution | Expected Parrot API key and sufficient usage credits | Expected Parrot runs the job and provides access to supported models. |
| Direct provider access | API key for each selected provider | EDSL runs on your machine and calls the provider; provider charges apply. |
| Local model server | Endpoint configuration and any server credentials | EDSL calls a server you operate. See [Local models](https://docs.expectedparrot.com/en/latest/language_models.md#connect-to-your-own-model-server). |

Local execution describes where the job is orchestrated. A locally orchestrated job can still send requests to a remote provider.

## Expected Parrot

### Log in from a notebook

Run this in a notebook cell:

```python theme={null}
from edsl import login

login()
```

Follow the sign-in link in the cell output to log in to [Expected Parrot](https://www.expectedparrot.com). EDSL retrieves your API key, saves it in a local `.env` file, and makes it available to the current notebook session. You do not need to copy or paste the key.

If a valid key is already configured, `login()` reports the signed-in user. These optional arguments let you sign in again or allow more time to finish:

```python theme={null}
# Sign in again, for example to use a different account:
# login(force=True)

# Allow five minutes to finish signing in (the default is two minutes):
# login(timeout=300)
```

### Use an existing API key

You can also obtain a key from your Expected Parrot account settings and supply it through the `EXPECTED_PARROT_API_KEY` environment variable or your environment's secret manager. Keep the key and any `.env` file containing it private.

For automation, configure the environment variable before starting the process. These CLI commands check authentication and connectivity:

```bash theme={null}
ep auth status
ep check
```

Check each JSON response's `status` and error details. See [Remote execution](https://docs.expectedparrot.com/en/latest/remote_inference.md) for running and retrieving a job.

## Direct provider access

Configure the selected provider's key in its environment variable, such as `OPENAI_API_KEY` for OpenAI or `ANTHROPIC_API_KEY` for Anthropic. Select current identifiers from the model catalog:

```python theme={null}
from edsl import Model

available = Model.available(service_name="openai")
```

Catalog discovery may require network access. Use [Provider configuration](https://docs.expectedparrot.com/en/latest/guides/providers.md) for Azure and model-specific parameters. Do not assume every provider supports the same model options.

For a job constructed with your selected model, call the provider directly from Python:

```python theme={null}
results = job.run(disable_remote_inference=True, disable_remote_cache=True)
```

These settings run the job from your environment and keep it from using Expected Parrot's hosted response cache. For a saved job, the CLI alternative is:

```bash theme={null}
ep run jobs.ep --local --output results.ep
```

See [Jobs](https://docs.expectedparrot.com/en/latest/jobs.md) for constructing a job and [Local caching](https://docs.expectedparrot.com/en/latest/cache.md) for saving and reusing responses.

## Loading a local .env file

If you use a local `.env` file, exclude it from version control and load it before constructing clients:

```python theme={null}
from dotenv import load_dotenv

load_dotenv()
```

The file contains environment variable assignments; use the names above with your own secret values. In Colab, use its [Secrets panel](https://docs.expectedparrot.com/en/latest/colab_setup.md) instead of embedding keys in cells.

## Troubleshooting access

Use `ep info` for redacted diagnostics. For Expected Parrot, use `ep auth status` and `ep check`. For a direct provider, confirm that its key is configured and that the account has access to the selected model. Correct authentication errors before retrying a job.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.