Ungraded lab - M2_UGL_1 - model choice invalid

In the notebook, M2_UGL_1When I experiment with changing the generation or reflection model in the workflow, I get this error if I try to use ‘claude-3–7-sonnet’ for the reflection model:

PermissionDeniedError: Error code: 403 - {'error': {'message': 'using claude-3-7-sonnet is invalid'}}

What Claude models are available to try?

1 Like

Looks like using “claude-3-7-sonnet-latest” as model name would work.

reflection_model=“claude-3-7-sonnet-latest” #“o4-mini”

@greenvinyl can you give it a try on your side?

2 Likes

I had the same issue. On the notebook it says:

“Use a stronger reasoning model for reflection (gpt-4.1 or claude-3-7-sonnet).”

I tried with

reflection_model=“claude-3-7-sonnet”

and returned an error. The error included this page Model deprecations - Claude Docs

I tried with:

reflection_model=“claude-3-7-sonnet-latest”

and

reflection_model=“claude-3-7-sonnet-20250219”

and on both cases it worked alright.

2 Likes

@hguan Thank you - both your suggestions worked fine.

1 Like

@Lluichi Thank you - both your suggestions worked for me too.

While changing the generation model from original “gpt-4o-mini” to “gpt-3.5-turbo” got the following error:

====
Step 2: Executing chart code (V1)… :laptop:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
   3811 try:
-> 3812     return self._engine.get_loc(casted_key)
   3813 except KeyError as err:

File pandas/_libs/index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:7088, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:7096, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'year'

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
Cell In[26], line 8
      5 image_basename="drink_sales"
      7 # Run the complete agentic workflow
----> 8 _ = run_workflow(
      9     dataset_path="coffee_sales.csv",
     10     user_instructions=user_instructions,
     11     generation_model=generation_model,
     12     reflection_model=reflection_model,
     13     image_basename=image_basename
     14 )

Cell In[23], line 41, in run_workflow(dataset_path, user_instructions, generation_model, reflection_model, image_basename)
     39     initial_code = match.group(1).strip()
     40     exec_globals = {"df": df}
---> 41     exec(initial_code, exec_globals)
     42 utils.print_html(out_v1, is_image=True, title="Generated Chart (V1)")
     44 # 3) Reflect on V1 (image + original code) to get feedback and refined code (V2)

File <string>:6

File /usr/local/lib/python3.11/site-packages/pandas/core/frame.py:4113, in DataFrame.__getitem__(self, key)
   4111 if self.columns.nlevels > 1:
   4112     return self._getitem_multilevel(key)
-> 4113 indexer = self.columns.get_loc(key)
   4114 if is_integer(indexer):
   4115     indexer = [indexer]

File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3819, in Index.get_loc(self, key)
   3814     if isinstance(casted_key, slice) or (
   3815         isinstance(casted_key, abc.Iterable)
   3816         and any(isinstance(x, slice) for x in casted_key)
   3817     ):
   3818         raise InvalidIndexError(key)
-> 3819     raise KeyError(key) from err
   3820 except TypeError:
   3821     # If we have a listlike key, _check_indexing_error will raise
   3822     #  InvalidIndexError. Otherwise we fall through and re-raise
   3823     #  the TypeError.
   3824     self._check_indexing_error(key)

KeyError: 'year'
================

Need help

Welcome @Achint_Aggarwal! Try “gpt-3.5-turbo-0125” - I’ve just tested and it worked for me. Some gpt 3.5 models have been deprecated - I’m not sure if that is what is affecting this but hopefully this fixes it for you.

Got the same error.

I’m sorry but I’m not sure what else to suggest. I’m wondering if @hguan @Lluichi have any ideas?

Hi Achint_Aggarwal,

I get the same error messages. A plausible conclusion is that gpt-3.5-turbo is a less powerful coding model than gpt-4o-mini. So gpt-3.5-turbo may only be useful for initial code generation which needs to be debugged. This is currently still a common experience when using LLMs for coding.

@Achint_Aggarwal per the stacktrace, looks like the error is from LLM generated code execution. It will be helpful if the generated code is shared here.

btw: I agree with others shared, that different models have different coding capability therefore might generate code differently, sometimes with bugs. This seems to be one of those cases.

Detailed investigation: Anthropic / Claude models are not usable in the DeepLearning.AI lab (OpenAI models work)

I attempted to run a workflow in the DeepLearning.AI lab using an Anthropic (Claude) model (e.g. claude-3-7-sonnet-latest) and consistently encountered errors such as:

  • ConnectError: [Errno -2] Name or service not known

  • APIConnectionError: Connection error

At first glance, these errors appear to indicate DNS or network problems, but after a detailed investigation, the root cause turned out to be different.


What was tested

  1. DNS resolution

    • socket.gethostbyname("api.anthropic.com") resolves correctly
  2. Network / firewall

    • TCP connection to api.anthropic.com:443 succeeds

    • HTTPS GET requests to https://api.anthropic.com return a normal 404 response

  3. HTTPS POST to the Anthropic API

    • A direct httpx.post() call to https://api.anthropic.com/v1/messages succeeds at the network level

    • The response is consistently:

      401 authentication_error: invalid x-api-key
      

Key finding

The lab environment does not provide a valid ANTHROPIC_API_KEY, and externally supplied Anthropic API keys do not appear to be usable. As a result:

  • Anthropic API calls fail due to authentication

  • The Anthropic Python SDK surfaces this as a generic APIConnectionError, which can be misleading and looks like a connectivity issue


OpenAI models work as expected

Using the OpenAI models provided/suggested by the lab works correctly, including:

  • gpt-4o-mini

  • gpt-4.1-mini

  • gpt-4.1

When switching the workflow to any of these OpenAI models, the same code runs successfully without connection or authentication errors.


Conclusion

  • Anthropic / Claude models are not supported in the DeepLearning.AI lab environment

  • The lab is intended to be used with the OpenAI models provided by the course

  • If you encounter connection-style errors when trying to use Claude, the solution is to switch to one of the supported OpenAI models listed above