Claude Code vs OpenAI SDK: Troubleshooting gpt-oss-120b Developers using the Anthropic SDK to access Sakura AI Engine's gpt-oss-120b model must replace the standard api_key parameter with auth_token for Bearer authentication and filter response content by type to avoid crashes, as the SDK's default handling of thinking blocks causes attribute errors. The OpenAI SDK offers a more seamless experience with flat string responses and standard API keys, highlighting that "compatible" endpoints require provider-specific tweaks. 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/