# Claude Code vs OpenAI SDK: Troubleshooting gpt-oss-120b

> Source: <https://promptcube3.com/en/threads/2591/>
> Published: 2026-07-23 23:01:27+00:00

# Claude Code vs OpenAI SDK: Troubleshooting gpt-oss-120b

`gpt-oss-120b`

to run through the Anthropic SDK is a lesson in how "compatibility" varies between LLM providers. While Sakura AI Engine hosts this open-weight model with both OpenAI and Anthropic-compatible endpoints, the implementation details differ enough to trip up anyone expecting a plug-and-play experience.## The Authentication Trap

The most immediate hurdle is the `401 Unauthorized`

error. If you use the standard `api_key`

parameter in the Anthropic Python SDK, it sends the token via the `x-api-key`

header. However, some compatible endpoints—including Sakura's—expect a Bearer token.

To fix this, you have to swap the parameter name. Instead of `api_key=""`

, use `auth_token=""`

. This is the same underlying mechanism used by [Claude](/en/tags/claude/) Code for `ANTHROPIC_AUTH_TOKEN`

.

## Handling Response Payloads

Once authenticated, you'll likely hit a runtime error when trying to print the response. The standard habit of accessing `resp.content[0].text`

will fail with:`'ThinkingBlock' object has no attribute 'text'`

This happens because reasoning models often return a mix of content types (like thinking blocks and text blocks). Indexing the first element blindly is a recipe for a crash. The only stable way to extract the actual answer is to filter the content list:

```
# Avoid resp.content[0].text
actual_text = [b.text for b in resp.content if b.type == "text"]
```

## Performance & Setup

For those looking for a practical tutorial on the setup, the OpenAI-compatible route is seamless, but the Anthropic SDK requires the specific tweaks mentioned above.

**Comparison: OpenAI SDK vs Anthropic SDK on Sakura**

**Auth Method:** OpenAI uses standard API keys; Anthropic SDK requires`auth_token`

for Bearer auth.**Response Structure:** OpenAI returns a flat string in`message.content`

; Anthropic returns a list of content blocks that must be filtered.**Reliability:** The OpenAI endpoint is more stable for this specific model deployment.

If you're building an AI workflow that needs to switch between providers, don't assume that "compatible" means "identical." Always verify how the SDK handles headers and response objects. For a deep dive into managing these different API behaviors, check out promptcube3.com.

[Next DQN vs Q-Learning: Scaling RL with Neural Networks →](/en/threads/2568/)
